From bfaeb71cb8d8fc421253a18919b2e561e09ab741 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Mon, 8 Apr 2019 23:19:12 +0200 Subject: [PATCH] build: create config even when docs are disabled Fixes #1733 --- .gitignore | 1 + CMakeLists.txt | 97 +++++++++++++++++++++++++++++ cmake/templates/userconfig.cmake.in | 2 +- doc/config.cmake => config.cmake | 0 doc/.gitignore | 1 - doc/CMakeLists.txt | 97 ----------------------------- 6 files changed, 99 insertions(+), 99 deletions(-) rename doc/config.cmake => config.cmake (100%) delete mode 100644 doc/.gitignore diff --git a/.gitignore b/.gitignore index 73516271..acd8ed52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /build /tags /compile_commands.json +/config *.bak *.pyc *.swp diff --git a/CMakeLists.txt b/CMakeLists.txt index e26cbe28..d0a63fb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,3 +70,100 @@ if(BUILD_TESTS) enable_testing() add_subdirectory(tests) endif() + + +# +# Generate configuration file +# + +set(MODULES_LEFT "bspwm i3") +set(MODULES_CENTER "mpd") +set(MODULES_RIGHT "filesystem xbacklight alsa pulseaudio xkeyboard memory cpu wlan eth battery temperature date powermenu") + +set(FONT_FIXED "fixed:pixelsize=10") +set(FONT_UNIFONT "unifont:fontformat=truetype") +set(FONT_SIJI "siji:pixelsize=10") + +queryfont(FONT_FIXED ${FONT_FIXED} FIELDS family pixelsize) +queryfont(FONT_UNIFONT ${FONT_UNIFONT} FIELDS family fontformat) +queryfont(FONT_SIJI ${FONT_SIJI} FIELDS family pixelsize) + +# Strip disabled modules {{{ + +if(NOT ENABLE_PULSEAUDIO) + string(REPLACE " pulseaudio" "" MODULES_RIGHT ${MODULES_RIGHT}) +endif() +if(NOT ENABLE_ALSA) + string(REPLACE " alsa" "" 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_CENTER ${MODULES_CENTER}) +endif() +if(NOT ENABLE_NETWORK) + string(REPLACE " wlan eth" "" MODULES_RIGHT ${MODULES_RIGHT}) +endif() +if(NOT WITH_XRANDR) + string(REPLACE "xbacklight " "backlight-acpi " MODULES_RIGHT ${MODULES_RIGHT}) +endif() +if(NOT WITH_XKB) + string(REPLACE "xkeyboard " "" MODULES_RIGHT ${MODULES_RIGHT}) +endif() + +# }}} +# Get battery/adapter name {{{ + +string(REGEX REPLACE /%battery%.* "" PATH_BAT ${SETTING_PATH_BATTERY}) +string(REGEX REPLACE /%adapter%.* "" PATH_ADP ${SETTING_PATH_ADAPTER}) +file(GLOB BAT_LIST RELATIVE ${PATH_BAT} ${PATH_ADP}/B*) +file(GLOB ADP_LIST RELATIVE ${PATH_ADP} ${PATH_ADP}/A*) +if(BAT_LIST) + list(GET BAT_LIST 0 BATTERY) +else() + set(BATTERY BAT0) +endif() +if(ADP_LIST) + list(GET ADP_LIST 0 ADAPTER) +else() + set(ADAPTER ADP1) +endif() + +# }}} +# Get network interfaces {{{ + +if(ENABLE_NETWORK) + file(GLOB IFLIST RELATIVE /sys/class/net /sys/class/net/*) + foreach(INTERFACE ${IFLIST}) + if(NOT ${INTERFACE} STREQUAL "lo") + file(GLOB IS_WIRELESS /sys/class/net/${INTERFACE}/wireless) + if(IS_WIRELESS) + set(INTERFACE_WLAN ${INTERFACE}) + else() + set(INTERFACE_ETH ${INTERFACE}) + endif() + endif() + endforeach() + if(NOT INTERFACE_ETH) + set(INTERFACE_ETH net0) + endif() + if(NOT INTERFACE_WLAN) + set(INTERFACE_WLAN net1) + endif() +endif() + +# }}} +# Configure and install {{{ + +configure_file( + ${CMAKE_CURRENT_LIST_DIR}/config.cmake + ${CMAKE_CURRENT_LIST_DIR}/config + ESCAPE_QUOTES @ONLY) + +install(FILES config + DESTINATION share/doc/polybar + COMPONENT config) + +# }}} + diff --git a/cmake/templates/userconfig.cmake.in b/cmake/templates/userconfig.cmake.in index 300f1543..9d05c60e 100644 --- a/cmake/templates/userconfig.cmake.in +++ b/cmake/templates/userconfig.cmake.in @@ -4,5 +4,5 @@ if(NOT USER_CONFIG_HOME) endif() set(USER_CONFIG_HOME "${USER_CONFIG_HOME}/polybar") -file(INSTALL "@CMAKE_SOURCE_DIR@/doc/config" +file(INSTALL "@CMAKE_SOURCE_DIR@/config" DESTINATION "${USER_CONFIG_HOME}") diff --git a/doc/config.cmake b/config.cmake similarity index 100% rename from doc/config.cmake rename to config.cmake diff --git a/doc/.gitignore b/doc/.gitignore deleted file mode 100644 index 04204c7c..00000000 --- a/doc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -config diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index d9c4ad9e..948f8f48 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,99 +1,3 @@ -# -# Generate configuration file -# - -set(MODULES_LEFT "bspwm i3") -set(MODULES_CENTER "mpd") -set(MODULES_RIGHT "filesystem xbacklight alsa pulseaudio xkeyboard memory cpu wlan eth battery temperature date powermenu") - -set(FONT_FIXED "fixed:pixelsize=10") -set(FONT_UNIFONT "unifont:fontformat=truetype") -set(FONT_SIJI "siji:pixelsize=10") - -queryfont(FONT_FIXED ${FONT_FIXED} FIELDS family pixelsize) -queryfont(FONT_UNIFONT ${FONT_UNIFONT} FIELDS family fontformat) -queryfont(FONT_SIJI ${FONT_SIJI} FIELDS family pixelsize) - -# Strip disabled modules {{{ - -if(NOT ENABLE_PULSEAUDIO) - string(REPLACE " pulseaudio" "" MODULES_RIGHT ${MODULES_RIGHT}) -endif() -if(NOT ENABLE_ALSA) - string(REPLACE " alsa" "" 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_CENTER ${MODULES_CENTER}) -endif() -if(NOT ENABLE_NETWORK) - string(REPLACE " wlan eth" "" MODULES_RIGHT ${MODULES_RIGHT}) -endif() -if(NOT WITH_XRANDR) - string(REPLACE "xbacklight " "backlight-acpi " MODULES_RIGHT ${MODULES_RIGHT}) -endif() -if(NOT WITH_XKB) - string(REPLACE "xkeyboard " "" MODULES_RIGHT ${MODULES_RIGHT}) -endif() - -# }}} -# Get battery/adapter name {{{ - -string(REGEX REPLACE /%battery%.* "" PATH_BAT ${SETTING_PATH_BATTERY}) -string(REGEX REPLACE /%adapter%.* "" PATH_ADP ${SETTING_PATH_ADAPTER}) -file(GLOB BAT_LIST RELATIVE ${PATH_BAT} ${PATH_ADP}/B*) -file(GLOB ADP_LIST RELATIVE ${PATH_ADP} ${PATH_ADP}/A*) -if(BAT_LIST) - list(GET BAT_LIST 0 BATTERY) -else() - set(BATTERY BAT0) -endif() -if(ADP_LIST) - list(GET ADP_LIST 0 ADAPTER) -else() - set(ADAPTER ADP1) -endif() - -# }}} -# Get network interfaces {{{ - -if(ENABLE_NETWORK) - file(GLOB IFLIST RELATIVE /sys/class/net /sys/class/net/*) - foreach(INTERFACE ${IFLIST}) - if(NOT ${INTERFACE} STREQUAL "lo") - file(GLOB IS_WIRELESS /sys/class/net/${INTERFACE}/wireless) - if(IS_WIRELESS) - set(INTERFACE_WLAN ${INTERFACE}) - else() - set(INTERFACE_ETH ${INTERFACE}) - endif() - endif() - endforeach() - if(NOT INTERFACE_ETH) - set(INTERFACE_ETH net0) - endif() - if(NOT INTERFACE_WLAN) - set(INTERFACE_WLAN net1) - endif() -endif() - -# }}} -# Configure and install {{{ - -configure_file( - ${CMAKE_CURRENT_LIST_DIR}/config.cmake - ${CMAKE_CURRENT_LIST_DIR}/config - ESCAPE_QUOTES @ONLY) - -install(FILES config - DESTINATION share/doc/polybar - COMPONENT config) - -# }}} - -# Documentation {{{ find_program(SPHINX_EXECUTABLE NAMES sphinx-build DOC "Sphinx Documentation Builder") @@ -142,4 +46,3 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 COMPONENT doc) -# }}}