2016-11-11 19:40:19 +00:00
|
|
|
#
|
|
|
|
# Generate configuration file
|
|
|
|
#
|
|
|
|
|
2017-01-24 10:59:10 +00:00
|
|
|
set(MODULES_LEFT "bspwm i3")
|
|
|
|
set(MODULES_CENTER "mpd")
|
2018-02-16 02:49:04 +00:00
|
|
|
set(MODULES_RIGHT "filesystem xbacklight alsa pulseaudio xkeyboard memory cpu wlan eth battery temperature date powermenu")
|
2016-11-11 19:40:19 +00:00
|
|
|
|
2017-01-13 21:42:10 +00:00
|
|
|
set(FONT_FIXED "fixed:pixelsize=10")
|
|
|
|
set(FONT_UNIFONT "unifont:fontformat=truetype")
|
|
|
|
set(FONT_SIJI "siji:pixelsize=10")
|
|
|
|
|
2017-01-26 16:17:02 +00:00
|
|
|
queryfont(FONT_FIXED ${FONT_FIXED} FIELDS family pixelsize)
|
|
|
|
queryfont(FONT_UNIFONT ${FONT_UNIFONT} FIELDS family fontformat)
|
|
|
|
queryfont(FONT_SIJI ${FONT_SIJI} FIELDS family pixelsize)
|
2017-01-13 21:42:10 +00:00
|
|
|
|
2016-11-11 19:40:19 +00:00
|
|
|
# Strip disabled modules {{{
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2018-02-15 10:26:59 +00:00
|
|
|
if(NOT ENABLE_PULSEAUDIO)
|
|
|
|
string(REPLACE " pulseaudio" "" MODULES_RIGHT ${MODULES_RIGHT})
|
|
|
|
endif()
|
2017-09-26 22:21:23 +00:00
|
|
|
if(NOT ENABLE_ALSA)
|
2018-02-16 02:49:04 +00:00
|
|
|
string(REPLACE " alsa" "" MODULES_RIGHT ${MODULES_RIGHT})
|
2016-11-11 19:40:19 +00:00
|
|
|
endif()
|
|
|
|
if(NOT ENABLE_I3)
|
|
|
|
string(REPLACE " i3" "" MODULES_LEFT ${MODULES_LEFT})
|
|
|
|
endif()
|
2017-01-24 10:59:10 +00:00
|
|
|
if(NOT ENABLE_MPD)
|
|
|
|
string(REPLACE "mpd" "" MODULES_CENTER ${MODULES_CENTER})
|
|
|
|
endif()
|
2016-11-11 19:40:19 +00:00
|
|
|
if(NOT ENABLE_NETWORK)
|
|
|
|
string(REPLACE " wlan eth" "" MODULES_RIGHT ${MODULES_RIGHT})
|
|
|
|
endif()
|
2016-11-30 11:46:26 +00:00
|
|
|
if(NOT WITH_XRANDR)
|
2017-01-13 02:52:56 +00:00
|
|
|
string(REPLACE "xbacklight " "backlight-acpi " MODULES_RIGHT ${MODULES_RIGHT})
|
2016-11-11 19:40:19 +00:00
|
|
|
endif()
|
2016-12-03 22:22:09 +00:00
|
|
|
if(NOT WITH_XKB)
|
|
|
|
string(REPLACE "xkeyboard " "" MODULES_RIGHT ${MODULES_RIGHT})
|
|
|
|
endif()
|
2016-11-11 19:40:19 +00:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
# Get battery/adapter name {{{
|
|
|
|
|
2016-11-21 07:22:12 +00:00
|
|
|
string(REGEX REPLACE /%battery%.* "" PATH_BAT ${SETTING_PATH_BATTERY})
|
|
|
|
string(REGEX REPLACE /%adapter%.* "" PATH_ADP ${SETTING_PATH_ADAPTER})
|
2016-11-11 19:40:19 +00:00
|
|
|
file(GLOB BAT_LIST RELATIVE ${PATH_BAT} ${PATH_ADP}/B*)
|
|
|
|
file(GLOB ADP_LIST RELATIVE ${PATH_ADP} ${PATH_ADP}/A*)
|
2016-11-12 14:03:45 +00:00
|
|
|
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()
|
2016-11-11 19:40:19 +00:00
|
|
|
|
2016-11-20 03:11:02 +00:00
|
|
|
# }}}
|
|
|
|
# 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()
|
|
|
|
|
2016-11-11 19:40:19 +00:00
|
|
|
# }}}
|
|
|
|
# Configure and install {{{
|
|
|
|
|
|
|
|
configure_file(
|
2017-01-26 19:36:00 +00:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/config.cmake
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/config
|
2016-11-11 19:40:19 +00:00
|
|
|
ESCAPE_QUOTES @ONLY)
|
|
|
|
|
|
|
|
install(FILES config
|
2016-12-23 17:10:19 +00:00
|
|
|
DESTINATION share/doc/polybar
|
2016-06-15 03:32:35 +00:00
|
|
|
COMPONENT config)
|
|
|
|
|
2016-11-11 19:40:19 +00:00
|
|
|
# }}}
|
2018-12-01 13:10:03 +00:00
|
|
|
|
|
|
|
# Documentation {{{
|
2018-12-14 15:16:20 +00:00
|
|
|
find_program(SPHINX_EXECUTABLE
|
|
|
|
NAMES sphinx-build
|
|
|
|
DOC "Sphinx Documentation Builder")
|
|
|
|
|
|
|
|
if(NOT SPHINX_EXECUTABLE)
|
|
|
|
message_colored(FATAL_ERROR "Failed to locate sphinx-build" 31)
|
|
|
|
endif()
|
|
|
|
|
2019-01-03 19:24:21 +00:00
|
|
|
# Configures conf.py in the current folder and puts it in the build folder
|
|
|
|
configure_file(conf.py conf.py @ONLY)
|
2018-12-01 13:10:03 +00:00
|
|
|
|
2018-12-14 08:34:31 +00:00
|
|
|
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
|
|
|
|
separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
|
2018-12-01 13:10:03 +00:00
|
|
|
|
2018-12-14 08:34:31 +00:00
|
|
|
set(doc_path "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
|
|
|
|
# We want to run `sphinx-build` with the following builders
|
|
|
|
set(doc_builders "html" "man")
|
|
|
|
|
|
|
|
# Name of all documentation targets
|
|
|
|
set(doc_targets "")
|
|
|
|
|
|
|
|
foreach(builder ${doc_builders})
|
|
|
|
set(doc_target "doc_${builder}")
|
|
|
|
set(builder_log "builder-${builder}.log")
|
|
|
|
add_custom_target(${doc_target}
|
2018-12-14 15:16:20 +00:00
|
|
|
COMMAND ${SPHINX_EXECUTABLE}
|
2018-12-14 08:34:31 +00:00
|
|
|
-b ${builder}
|
|
|
|
-c "${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
-d "${CMAKE_CURRENT_BINARY_DIR}/doctrees"
|
|
|
|
${sphinx_flags}
|
|
|
|
"${CMAKE_SOURCE_DIR}/doc"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${builder}" > ${builder_log}
|
|
|
|
COMMENT "sphinx-build ${builder}: see doc/${builder_log}")
|
|
|
|
|
|
|
|
list(APPEND doc_targets ${doc_target})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Dummy target that depends on all documentation targets
|
|
|
|
add_custom_target(doc ALL DEPENDS ${doc_targets})
|
|
|
|
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
|
2018-12-01 13:10:03 +00:00
|
|
|
DESTINATION share/doc/polybar
|
|
|
|
COMPONENT doc)
|
|
|
|
|
2018-12-14 08:34:31 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.1
|
2018-12-02 18:17:26 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
|
|
|
|
COMPONENT doc)
|
2018-12-01 13:10:03 +00:00
|
|
|
# }}}
|