From 05c318e97b4231b404101edb6095384b62a9822f Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 11 Nov 2016 20:40:19 +0100 Subject: [PATCH] feat(config): Generate config based on build --- cmake/build/targets.cmake | 11 + cmake/templates/userconfig.cmake.in | 7 + cmake/uninstall.cmake.in | 26 -- examples/CMakeLists.txt | 56 ++++- examples/config | 326 ++++++++++++++---------- examples/config.bspwm | 376 ---------------------------- examples/config.cmake | 328 ++++++++++++++++++++++++ examples/config.i3 | 85 ------- 8 files changed, 583 insertions(+), 632 deletions(-) create mode 100644 cmake/templates/userconfig.cmake.in delete mode 100644 cmake/uninstall.cmake.in delete mode 100644 examples/config.bspwm create mode 100644 examples/config.cmake delete mode 100644 examples/config.i3 diff --git a/cmake/build/targets.cmake b/cmake/build/targets.cmake index bf108b62..b1703eb4 100644 --- a/cmake/build/targets.cmake +++ b/cmake/build/targets.cmake @@ -2,6 +2,17 @@ # Custom targets # +# Target: userconfig {{{ + +configure_file( + ${PROJECT_SOURCE_DIR}/cmake/templates/userconfig.cmake.in + ${PROJECT_BINARY_DIR}/userconfig.cmake + IMMEDIATE @ONLY) + +add_custom_target(userconfig COMMAND ${CMAKE_COMMAND} + -P ${PROJECT_BINARY_DIR}/userconfig.cmake) + +# }}} # Target: uninstall {{{ configure_file( diff --git a/cmake/templates/userconfig.cmake.in b/cmake/templates/userconfig.cmake.in new file mode 100644 index 00000000..55106949 --- /dev/null +++ b/cmake/templates/userconfig.cmake.in @@ -0,0 +1,7 @@ +set(USER_CONFIG_HOME $ENV{XDG_CONFIG_HOME}) +if(NOT USER_CONFIG_HOME) + set(USER_CONFIG_HOME $ENV{HOME}/.config) +endif() +set(USER_CONFIG_HOME ${USER_CONFIG_HOME}/lemonbuddy) + +file(INSTALL @CMAKE_SOURCE_DIR@/examples/config DESTINATION ${USER_CONFIG_HOME}) diff --git a/cmake/uninstall.cmake.in b/cmake/uninstall.cmake.in deleted file mode 100644 index 5e30cb44..00000000 --- a/cmake/uninstall.cmake.in +++ /dev/null @@ -1,26 +0,0 @@ -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/examples/CMakeLists.txt b/examples/CMakeLists.txt index e92328f3..a9928b01 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,13 +1,51 @@ +# +# Generate configuration file +# + +set(MODULES_LEFT "bspwm i3 mpd") +set(MODULES_CENTER "") +set(MODULES_RIGHT "backlight volume memory cpu wlan eth battery temperature date powermenu") + +# Strip disabled modules {{{ + +if(NOT ENABLE_ALSA) + string(REPLACE " volume" "" MODULES_RIGHT ${MODULES_RIGHT}) +endif() +if(NOT ENABLE_I3) + string(REPLACE " i3" "" MODULES_LEFT ${MODULES_LEFT}) +endif() +if(NOT ENABLE_MPD) + string(REPLACE " mpd" "" MODULES_LEFT ${MODULES_LEFT}) +endif() +if(NOT ENABLE_NETWORK) + string(REPLACE " wlan eth" "" MODULES_RIGHT ${MODULES_RIGHT}) +endif() +if(NOT ENABLE_RANDR_EXT) + string(REPLACE "backlight " "" MODULES_RIGHT ${MODULES_RIGHT}) +endif() + +# }}} +# Get battery/adapter name {{{ + +string(REGEX REPLACE /%battery%.* "" PATH_BAT ${SETTING_PATH_BATTERY_CAPACITY}) +string(REGEX REPLACE /%adapter%.* "" PATH_ADP ${SETTING_PATH_ADAPTER_STATUS}) + +file(GLOB BAT_LIST RELATIVE ${PATH_BAT} ${PATH_ADP}/B*) +file(GLOB ADP_LIST RELATIVE ${PATH_ADP} ${PATH_ADP}/A*) + +list(GET BAT_LIST 0 BATTERY) +list(GET ADP_LIST 0 ADAPTER) + +# }}} +# Configure and install {{{ + +configure_file( + ${PROJECT_SOURCE_DIR}/examples/config.cmake + ${CMAKE_SOURCE_DIR}/examples/config + ESCAPE_QUOTES @ONLY) + install(FILES config DESTINATION share/examples/lemonbuddy COMPONENT config) -install(FILES config.bspwm - DESTINATION share/examples/lemonbuddy - COMPONENT config) - -if(ENABLE_I3) - install(FILES config.i3 - DESTINATION share/examples/lemonbuddy - COMPONENT config) -endif() +# }}} diff --git a/examples/config b/examples/config index 9e676cba..6cdb50ec 100644 --- a/examples/config +++ b/examples/config @@ -7,17 +7,24 @@ ; ;===================================================== +[global/wm] +margin-top = 5 +margin-bottom = 5 +margin-left = 5 +margin-right = 5 + + [bar/example] -monitor = eDP-1 -dock = true +;monitor = HDMI-1 +dock = false width = 100% height = 27 offset-x = 0 offset-y = 0 background = #ee222222 -foreground = #ccfafafa -linecolor = #666 +foreground = #dfdfdf +linecolor = #555 border-bottom = 2 border-bottom-color = #333 @@ -29,18 +36,126 @@ padding-right = 2 module-margin-left = 1 module-margin-right = 2 -font-0 = tamzen:size=9;1 -font-1 = siji:pixelsize=10;0 -font-2 = unifont:size=6;-1 +font-0 = fixed:pixelsize=10;0 +font-1 = unifont:size=6;-2 +font-2 = siji:pixelsize=10;0 -modules-left = mpd -modules-center = date -modules-right = volume memory cpu +modules-left = bspwm i3 mpd +modules-center = +modules-right = backlight volume memory cpu wlan eth battery temperature date powermenu tray-position = right -tray-background = #33ffffff tray-padding = 4 +;wm-restack = bspwm + + +[module/bspwm] +type = internal/bspwm +ws-icon-default = x + +label-active = %index% +label-active-background = #ee333333 +label-active-underline= #cc333333 +label-active-padding = 2 + +label-occupied = %index% +label-occupied-padding = 2 + +label-urgent = %index% +label-urgent-background = #bd2c40 +label-urgent-padding = 2 + +label-empty = %index% +label-empty-foreground = #55 +label-empty-padding = 2 + + +[module/i3] +type = internal/i3 +format = +index-sort = true + +label-focused = %index% +label-focused-background = #ee333333 +label-focused-underline= #cc333333 +label-focused-padding = 2 + +label-unfocused = %index% +label-unfocused-padding = 2 + +label-urgent = %index%! +label-urgent-background = #bd2c40 +label-urgent-padding = 2 + +label-visible = %index% +label-visible-foreground = #55 +label-visible-padding = 2 + + +[module/mpd] +type = internal/mpd + +format-online = + +label-song-maxlen = 25 +label-song-ellipsis = true + +icon-prev =  +icon-seekb =  +icon-stop =  +icon-play =  +icon-pause =  +icon-next =  +icon-seekf =  + +icon-random =  +icon-repeat =  + +toggle-on-foreground = #e60053 +toggle-off-foreground = #66 + + +[module/backlight] +type = internal/xbacklight + +format =