commit eeefb3c61071ead6a1278c226e4e6090878b4963 Author: Michael Carlberg Date: Thu May 19 16:41:06 2016 +0200 init(git): Base commit diff --git a/.exrc b/.exrc new file mode 100644 index 00000000..712d7b8a --- /dev/null +++ b/.exrc @@ -0,0 +1,5 @@ +let &path.="include,src," +let g:alternateSearchPath = 'sfr:../src,sfr:../../src/modules,sfr:../../src/utils,sfr:../../src/interfaces,sfr:../../src/services,sfr:../../src/drawtypes,sfr:../include,sfr:../../include/modules,sfr:../../include/interfaces,sfr:../../include/utils,sfr:../../include/services,sfr:../../include/drawtypes,' +let g:alternateExtensions_cpp = 'hpp' +" let tag_path = expand("%:p:h") . "/tags" +set tags+=/home/jaagr/var/github/jaagr/lemonbuddy/tags diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..07d06bfc --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +build +tags +*.bak +*.pyc +*.tmp +include/config.hpp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..0b1468a4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,8 @@ +[submodule "contrib/lemonbar-sm-git"] + path = contrib/lemonbar-sm-git + url = https://github.com/jaagr/bar + branch = master +[submodule "contrib/i3ipcpp"] + path = contrib/i3ipcpp + url = https://github.com/jaagr/i3ipcpp + branch = master diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py new file mode 100644 index 00000000..652b4bbe --- /dev/null +++ b/.ycm_extra_conf.py @@ -0,0 +1,130 @@ +# Here's the license text for this file: +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# For more information, please refer to + +import os +import ycm_core + +flags = [ +'-std=c++14', +'-Wall', +'-Wextra', +'-Wpedantic', +] + +compilation_database_folder = '' + +if os.path.exists( compilation_database_folder ): + database = ycm_core.CompilationDatabase( compilation_database_folder ) +else: + database = None + +SOURCE_EXTENSIONS = ['.cpp', '.cxx', '.cc', '.c', '.m', '.mm'] + +def DirectoryOfThisScript(): + return os.path.dirname( os.path.abspath( __file__ ) ) + +flags.append('-I'+ DirectoryOfThisScript() +'/src') +flags.append('-I'+ DirectoryOfThisScript() +'/include') +flags.append('-I'+ DirectoryOfThisScript() +'/contrib/i3ipcpp/include') + +def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): + if not working_directory: + return list( flags ) + new_flags = [] + make_next_absolute = False + path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] + for flag in flags: + new_flag = flag + + if make_next_absolute: + make_next_absolute = False + if not flag.startswith( '/' ): + new_flag = os.path.join( working_directory, flag ) + + for path_flag in path_flags: + if flag == path_flag: + make_next_absolute = True + break + + if flag.startswith( path_flag ): + path = flag[ len( path_flag ): ] + new_flag = path_flag + os.path.join( working_directory, path ) + break + + if new_flag: + new_flags.append( new_flag ) + return new_flags + +def IsHeaderFile( filename ): + extension = os.path.splitext( filename )[ 1 ] + return extension in [ '.h', '.hxx', '.hpp', '.hh' ] + +def GetCompilationInfoForFile( filename ): + # The compilation_commands.json file generated by CMake does not have entries + # for header files. So we do our best by asking the db for flags for a + # corresponding source file, if any. If one exists, the flags for that file + # should be good enough. + if IsHeaderFile( filename ): + basename = os.path.splitext( filename )[ 0 ] + for extension in SOURCE_EXTENSIONS: + replacement_file = basename + extension + if os.path.exists( replacement_file ): + compilation_info = database.GetCompilationInfoForFile( + replacement_file ) + if compilation_info.compiler_flags_: + return compilation_info + return None + return database.GetCompilationInfoForFile( filename ) + + +def FlagsForFile( filename, **kwargs ): + # if database: + # # Bear in mind that compilation_info.compiler_flags_ does NOT return a + # # python list, but a "list-like" StringVec object + # compilation_info = GetCompilationInfoForFile( filename ) + # if not compilation_info: + # return None + # + # final_flags = MakeRelativePathsInFlagsAbsolute( + # compilation_info.compiler_flags_, + # compilation_info.compiler_working_dir_ ) + # + # # NOTE: This is just for YouCompleteMe; it's highly likely that your project + # # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR + # # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT. + # try: + # final_flags.remove( '-stdlib=libc++' ) + # except ValueError: + # pass + # else: + relative_to = DirectoryOfThisScript() + final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) + + return { + 'flags': final_flags, + 'do_cache': True + } diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..6143155d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,145 @@ +# +# Build configuration +# +cmake_minimum_required(VERSION 3.0) + +set(CMAKE_CXX_COMPILER "/usr/bin/clang++") + +project(lemonbuddy VERSION 1.0.0) + +set(CMAKE_MODULE_PATH + "${CMAKE_MODULE_PATH}" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Wpedantic -Wno-unused-parameter") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -DDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") + +# +# Internal values and switches +# +option(ENABLE_CCACHE "Enable ccache support" ON) +option(ENABLE_ALSA "Enable alsa support" ON) +option(ENABLE_MPD "Enable mpd support" ON) +option(ENABLE_I3 "Enable i3 support" OFF) + +message(STATUS "---------------------------") +message(STATUS " Enable ccache support ${ENABLE_CCACHE}") +message(STATUS " Enable mpd support ${ENABLE_MPD}") +message(STATUS " Enable alsa support ${ENABLE_ALSA}") +message(STATUS " Enable i3 support ${ENABLE_I3}") +message(STATUS "---------------------------") + +if(ENABLE_ALSA) + set(SETTING_ALSA_SOUNDCARD "default" + CACHE STRING "Name of the ALSA soundcard driver") +endif() + +if(ENABLE_MPD) + set(SETTING_MPD_HOST "127.0.0.1" + CACHE STRING "Address MPD is bound to") + set(SETTING_MPD_PASSWORD "" + CACHE STRING "Password required for authentication") + set(SETTING_MPD_PORT "6600" + CACHE STRING "Port MPD is bound to") +endif() + +set(SETTING_CONNECTION_TEST_IP "8.8.8.8" + CACHE STRING "Address to ping when testing network connection") +set(SETTING_PATH_BACKLIGHT_VAL "/sys/class/backlight/%card%/brightness" + CACHE STRING "Path to file containing the current backlight value") +set(SETTING_PATH_BACKLIGHT_MAX "/sys/class/backlight/%card%/max_brightness" + CACHE STRING "Path to file containing the maximum backlight value") +set(SETTING_PATH_BATTERY_WATCH "/sys/class/power_supply/%battery%/charge_now" + CACHE STRING "Path to attach inotify watch to") +set(SETTING_PATH_BATTERY_CAPACITY "/sys/class/power_supply/%battery%/capacity" + CACHE STRING "Path to file containing the current battery capacity") +set(SETTING_PATH_ADAPTER_STATUS "/sys/class/power_supply/%adapter%/online" + CACHE STRING "Path to file containing the current adapter status") +set(SETTING_BSPWM_SOCKET_PATH "/tmp/bspwm_0_0-socket" + CACHE STRING "Path to bspwm socket") +set(SETTING_BSPWM_STATUS_PREFIX "W" + CACHE STRING "Prefix prepended to the bspwm status line") +set(SETTING_PATH_CPU_INFO "/proc/stat" + CACHE STRING "Path to file containing cpu info") +set(SETTING_PATH_MEMORY_INFO "/proc/meminfo" + CACHE STRING "Path to file containing memory info") + +configure_file("${CMAKE_SOURCE_DIR}/include/config.hpp.cmake" "${CMAKE_SOURCE_DIR}/include/config.hpp" ESCAPE_QUOTES @ONLY) + +if(ENABLE_CCACHE) + find_program(CCACHE_FOUND "ccache") + if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache") + else() + message(WARNING "ccache not found. Ignoring the flag...") + endif() +endif() + +# +# Locate and insert libs +# +find_package("Boost" REQUIRED) +#find_package("Boost" REQUIRED "regex") +find_package("Threads" REQUIRED) +find_package("X11" REQUIRED "X11_Xrandr" "X11_Xutil" "X11_Xlib") + +include_directories( + "${PROJECT_SOURCE_DIR}/include" + ${Boost_INCLUDE_DIRS} + ${X11_INCLUDE_DIR} + ${X11_Xrandr_INCLUDE_PATH}) + +link_directories( + ${Boost_LIBRARY_DIRS} + ${X11_LIBRARY_DIRS}) + +set(LINK_LIBS + ${Boost_LIBRARIES} + ${X11_LIBRARIES} + ${X11_Xrandr_LIB} + ${CMAKE_THREAD_LIBS_INIT}) + +if(ENABLE_ALSA) + find_package("ALSA" REQUIRED) + include_directories(${ALSA_INCLUDE_DIRS}) + link_directories(${ALSA_LIBRARY_DIRS}) + set(LINK_LIBS ${LINK_LIBS} ${ALSA_LIBRARIES}) +endif() + +if(ENABLE_MPD) + find_package("LibMPDClient" REQUIRED) + include_directories(${LIBMPDCLIENT_INCLUDE_DIRS}) + link_directories(${LIBMPDCLIENT_LIBRARY_DIRS}) + set(LINK_LIBS ${LINK_LIBS} ${LIBMPDCLIENT_LIBRARY}) +endif() + +# +# Install executable and wrapper +# +add_subdirectory("${PROJECT_SOURCE_DIR}/src") +add_executable(${PROJECT_NAME} ${SOURCE_FILES}) + +if(ENABLE_I3) + add_subdirectory("${PROJECT_SOURCE_DIR}/contrib/i3ipcpp" EXCLUDE_FROM_ALL) + include_directories(${SIGCPP_INCLUDE_DIRS} ${I3IPCpp_INCLUDE_DIRS}) + link_directories(${SIGCPP_LIBRARY_DIRS} ${I3IPCpp_LIBRARY_DIRS}) + set(LINK_LIBS "${LINK_LIBS};${I3IPCpp_LIBRARIES}") +endif() + +target_link_libraries(${PROJECT_NAME} ${LINK_LIBS}) + +install(TARGETS ${PROJECT_NAME} DESTINATION "bin") +install(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/lemonbuddy_wrapper.sh" DESTINATION "bin") + +# +# Uninstall target +# +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/uninstall.cmake" + IMMEDIATE @ONLY) + +add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} + -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/uninstall.cmake") diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..13e205a8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +The MIT License (MIT) +Copyright (c) 2016 Michael Carlberg + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 00000000..b240c581 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +Lemonbuddy +========== + +A fast and easy-to-use wrapper for [Lemonbar](https://github.com/LemonBoy/bar/), +helping you to style and organize your favorite status bar. + +### Todo + +- Write this README +- Create build script to make it easier to build the project for people who + aren't familiar with cmake diff --git a/cmake/modules/FindLibMPDClient.cmake b/cmake/modules/FindLibMPDClient.cmake new file mode 100644 index 00000000..24bb7d4f --- /dev/null +++ b/cmake/modules/FindLibMPDClient.cmake @@ -0,0 +1,31 @@ +# - Try to find LibMPDClient +# Once done, this will define +# +# LIBMPDCLIENT_FOUND - System has LibMPDClient +# LIBMPDCLIENT_INCLUDE_DIRS - The LibMPDClient include directories +# LIBMPDCLIENT_LIBRARIES - The libraries needed to use LibMPDClient +# LIBMPDCLIENT_DEFINITIONS - Compiler switches required for using LibMPDClient + +find_package(PkgConfig) +pkg_check_modules(PC_LIBMPDCLIENT QUIET libmpdclient) +set(LIBMPDCLIENT_DEFINITIONS ${PC_LIBMPDCLIENT_CFLAGS_OTHER}) + +find_path(LIBMPDCLIENT_INCLUDE_DIR + NAMES mpd/player.h + HINTS ${PC_LIBMPDCLIENT_INCLUDEDIR} ${PC_LIBMPDCLIENT_INCLUDE_DIRS} +) + +find_library(LIBMPDCLIENT_LIBRARY + NAMES mpdclient + HINTS ${PC_LIBMPDCLIENT_LIBDIR} ${PC_LIBMPDCLIENT_LIBRARY_DIRS} +) + +set(LIBMPDCLIENT_LIBRARIES ${LIBMPDCLIENT_LIBRARY}) +set(LIBMPDCLIENT_INCLUDE_DIRS ${LIBMPDCLIENT_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibMPDClient DEFAULT_MSG + LIBMPDCLIENT_LIBRARY LIBMPDCLIENT_INCLUDE_DIR +) + +mark_as_advanced(LIBMPDCLIENT_LIBRARY LIBMPDCLIENT_INCLUDE_DIR) diff --git a/cmake/uninstall.cmake.in b/cmake/uninstall.cmake.in new file mode 100644 index 00000000..5e30cb44 --- /dev/null +++ b/cmake/uninstall.cmake.in @@ -0,0 +1,26 @@ +set(INSTALL_MANIFEST "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +if (NOT EXISTS ${INSTALL_MANIFEST}) + message(FATAL_ERROR + "Cannot find install manifest: + \"${INSTALL_MANIFEST}\"") +endif(NOT EXISTS ${INSTALL_MANIFEST}) + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +list(REVERSE files) + +foreach (file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (EXISTS "$ENV{DESTDIR}${file}") + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval) + if(NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/config b/config new file mode 100644 index 00000000..9e8ed4d3 --- /dev/null +++ b/config @@ -0,0 +1,947 @@ +; +; Bar configurations +; --------------------------------------- +; +; Quote the value to keep spaces: +; key = " value" +; +; Values for the current bar can be accessed using: +; ${BAR.foreground} +; +; Other values can be referenced using: +; ${section.key} +; +; format:NAME = +; label:NAME[:(foreground|background|(under|over)line|font|padding)] = +; icon:NAME[:(foreground|background|(under|over)line|font|padding)] = +; ramp:NAME:[0-9]+[:(foreground|background|(under|over)line|font|padding)] = +; animation:NAME:[0-9]+[:(foreground|background|(under|over)line|font|padding)] = +; +; bar:NAME:width = +; bar:NAME:format = (tokens: %fill% %indicator% %empty%) +; bar:NAME:foreground:[0-9]+ = +; bar:NAME:indicator[:(foreground|background|(under|over)line|font|padding)] = +; bar:NAME:fill[:(foreground|background|(under|over)line|font|padding)] = +; bar:NAME:empty[:(foreground|background|(under|over)line|font|padding)] = +; +; These keys can be used to style the module container +; format:NAME:spacing = N (unit: whitespace) +; format:NAME:padding = N (unit: whitespace) +; format:NAME:margin = N (unit: whitespace) +; format:NAME:offset = N (unit: pixels) +; format:NAME:foreground = #hexcolor +; format:NAME:background = #hexcolor +; format:NAME:underline = #hexcolor +; format:NAME:overline = #hexcolor +; +; Module types: +; internal/backlight +; internal/battery +; internal/bspwm +; internal/cpu +; internal/date +; internal/memory +; internal/mpd +; internal/network +; internal/rtorrent +; internal/volume +; +; custom/text +; content +; click:(left|middle|right) +; scroll:(up|down) +; custom/script +; exec +; interval +; format +; click:(left|middle|right) +; scroll:(up|down) +; custom/menu +; format +; label:open +; label:close +; menu:LEVEL:n +; menu:LEVEL:n:exec +; + +[bar/top] +monitor = eDP-1 +width = 100% +height = 30 +clickareas = 35 + +background = #222222 +foreground = #eefafafa +linecolor = ${bar/top.background} + +;separator = | + +spacing = 3 +lineheight = 14 +;padding_left = 5 +;padding_right = 2 +module_margin_left = 3 +module_margin_right = 3 + +font:0 = NotoSans-Regular:size=8;0 +font:1 = MaterialIcons:size=10;0 +font:2 = Termsynu:size=8;-1 +font:3 = FontAwesome:size=10;0 + +; modules:left = powermenu mpd +; modules:right = backlight volume wireless-network wired-network battery date +modules:right = battery + +[bar/bottom] +monitor = eDP-1 +bottom = true +width = 100% +height = 27 +;clickareas = 25 + +background = #111111 +foreground = #ccffffff +linecolor = ${bar/bottom.background} + +spacing = 3 +lineheight = 2 +;padding_left = 0 +padding_right = 4 +module_margin_left = 0 +module_margin_right = 6 + +; font:idx = font:size=N;offsetY +font:0 = NotoSans-Regular:size=8;0 +font:1 = Unifont:size=6;-3 +;font:1 = Termsynu:size=8;-1 +font:2 = FontAwesome:size=8;-2 +font:3 = NotoSans-Regular:size=8;-1 +font:4 = MaterialIcons:size=10;-1 + +modules:left = bspwm +modules:right = rtorrent cpu memory +; modules:right = cpu memory + +[bar/external_bottom] +monitor = HDMI-1 +bottom = true +width = 100% +height = 27 +;clickareas = 25 + +background = #111111 +foreground = #ccffffff +linecolor = ${bar/external_bottom.background} + +spacing = 3 +lineheight = 2 +;padding_left = 0 +padding_right = 3 +module_margin_left = 0 +module_margin_right = 6 + +font:0 = NotoSans-Regular:size=8;0 +font:1 = Unifont:size=6;-3 +font:2 = FontAwesome:size=8;-2 +font:3 = NotoSans-Regular:size=8;-1 +font:4 = MaterialIcons:size=10;0 + +modules:left = bspwm +modules:right = clock + + +[module/backlight] +type = internal/backlight + +; Use the following command to list available cards: +; $ ls -1 /sys/class/backlight/ +card = intel_backlight + +; Available tags: +;