2016-06-15 03:32:35 +00:00
|
|
|
#
|
2017-01-26 16:17:02 +00:00
|
|
|
# Configure src
|
2016-06-15 03:32:35 +00:00
|
|
|
#
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2019-06-12 00:02:27 +00:00
|
|
|
get_include_dirs(includes_dir)
|
|
|
|
get_sources_dirs(src_dir)
|
2019-06-15 15:12:57 +00:00
|
|
|
|
2022-01-22 19:35:37 +00:00
|
|
|
# Source tree {{{
|
|
|
|
|
|
|
|
set(ALSA_SOURCES
|
|
|
|
${src_dir}/adapters/alsa/control.cpp
|
|
|
|
${src_dir}/adapters/alsa/mixer.cpp
|
|
|
|
${src_dir}/modules/alsa.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(GITHUB_SOURCES ${src_dir}/modules/github.cpp ${src_dir}/utils/http.cpp)
|
|
|
|
|
|
|
|
set(I3_SOURCES
|
|
|
|
${src_dir}/modules/i3.cpp
|
|
|
|
${src_dir}/utils/i3.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(MPD_SOURCES
|
|
|
|
${src_dir}/adapters/mpd.cpp
|
|
|
|
${src_dir}/modules/mpd.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(NETWORK_SOURCES
|
|
|
|
${src_dir}/adapters/net.cpp
|
|
|
|
${src_dir}/modules/network.cpp
|
|
|
|
$<IF:$<BOOL:${WITH_LIBNL}>,${src_dir}/adapters/net_nl.cpp,${src_dir}/adapters/net_iw.cpp>
|
|
|
|
)
|
|
|
|
|
|
|
|
set(PULSEAUDIO_SOURCES
|
|
|
|
${src_dir}/adapters/pulseaudio.cpp
|
|
|
|
${src_dir}/modules/pulseaudio.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(XCURSOR_SOURCES ${src_dir}/x11/cursor.cpp)
|
|
|
|
|
|
|
|
set(XKB_SOURCES
|
|
|
|
${src_dir}/modules/xkeyboard.cpp
|
|
|
|
${src_dir}/x11/extensions/xkb.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(XRM_SOURCES ${src_dir}/x11/xresources.cpp)
|
|
|
|
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/settings.cpp.cmake
|
|
|
|
${CMAKE_BINARY_DIR}/generated-sources/settings.cpp
|
|
|
|
ESCAPE_QUOTES)
|
|
|
|
|
|
|
|
set(POLY_SOURCES
|
|
|
|
${CMAKE_BINARY_DIR}/generated-sources/settings.cpp
|
|
|
|
|
|
|
|
${src_dir}/adapters/script_runner.cpp
|
|
|
|
|
|
|
|
${src_dir}/cairo/utils.cpp
|
|
|
|
|
|
|
|
${src_dir}/components/bar.cpp
|
|
|
|
${src_dir}/components/builder.cpp
|
|
|
|
${src_dir}/components/command_line.cpp
|
|
|
|
${src_dir}/components/config.cpp
|
|
|
|
${src_dir}/components/config_parser.cpp
|
|
|
|
${src_dir}/components/controller.cpp
|
|
|
|
${src_dir}/components/logger.cpp
|
|
|
|
${src_dir}/components/renderer.cpp
|
|
|
|
${src_dir}/components/screen.cpp
|
|
|
|
${src_dir}/components/eventloop.cpp
|
|
|
|
|
|
|
|
${src_dir}/drawtypes/animation.cpp
|
|
|
|
${src_dir}/drawtypes/iconset.cpp
|
|
|
|
${src_dir}/drawtypes/layouticonset.cpp
|
|
|
|
${src_dir}/drawtypes/label.cpp
|
|
|
|
${src_dir}/drawtypes/progressbar.cpp
|
|
|
|
${src_dir}/drawtypes/ramp.cpp
|
|
|
|
|
|
|
|
${src_dir}/events/signal_emitter.cpp
|
|
|
|
${src_dir}/events/signal_receiver.cpp
|
|
|
|
|
|
|
|
${src_dir}/ipc/ipc.cpp
|
|
|
|
${src_dir}/ipc/decoder.cpp
|
|
|
|
${src_dir}/ipc/encoder.cpp
|
|
|
|
${src_dir}/ipc/util.cpp
|
|
|
|
|
|
|
|
${src_dir}/modules/backlight.cpp
|
|
|
|
${src_dir}/modules/battery.cpp
|
|
|
|
${src_dir}/modules/bspwm.cpp
|
|
|
|
${src_dir}/modules/counter.cpp
|
|
|
|
${src_dir}/modules/cpu.cpp
|
|
|
|
${src_dir}/modules/date.cpp
|
|
|
|
${src_dir}/modules/fs.cpp
|
|
|
|
${src_dir}/modules/ipc.cpp
|
|
|
|
${src_dir}/modules/memory.cpp
|
|
|
|
${src_dir}/modules/menu.cpp
|
|
|
|
${src_dir}/modules/meta/base.cpp
|
2022-10-16 19:09:32 +00:00
|
|
|
${src_dir}/modules/meta/factory.cpp
|
2022-01-22 19:35:37 +00:00
|
|
|
${src_dir}/modules/script.cpp
|
|
|
|
${src_dir}/modules/temperature.cpp
|
|
|
|
${src_dir}/modules/text.cpp
|
|
|
|
${src_dir}/modules/xbacklight.cpp
|
|
|
|
${src_dir}/modules/xwindow.cpp
|
|
|
|
${src_dir}/modules/xworkspaces.cpp
|
2022-04-15 21:50:04 +00:00
|
|
|
${src_dir}/modules/tray.cpp
|
|
|
|
|
2022-01-22 19:35:37 +00:00
|
|
|
|
|
|
|
${src_dir}/tags/action_context.cpp
|
|
|
|
${src_dir}/tags/context.cpp
|
|
|
|
${src_dir}/tags/dispatch.cpp
|
|
|
|
${src_dir}/tags/parser.cpp
|
|
|
|
|
|
|
|
${src_dir}/utils/actions.cpp
|
|
|
|
${src_dir}/utils/action_router.cpp
|
|
|
|
${src_dir}/utils/bspwm.cpp
|
|
|
|
${src_dir}/utils/color.cpp
|
|
|
|
${src_dir}/utils/command.cpp
|
|
|
|
${src_dir}/utils/concurrency.cpp
|
|
|
|
${src_dir}/utils/env.cpp
|
|
|
|
${src_dir}/utils/file.cpp
|
|
|
|
${src_dir}/utils/inotify.cpp
|
|
|
|
${src_dir}/utils/io.cpp
|
|
|
|
${src_dir}/utils/process.cpp
|
2023-05-15 11:06:21 +00:00
|
|
|
${src_dir}/utils/restack.cpp
|
2022-01-22 19:35:37 +00:00
|
|
|
${src_dir}/utils/socket.cpp
|
|
|
|
${src_dir}/utils/string.cpp
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 20:08:57 +00:00
|
|
|
${src_dir}/utils/units.cpp
|
2022-01-22 19:35:37 +00:00
|
|
|
|
|
|
|
${src_dir}/x11/atoms.cpp
|
|
|
|
${src_dir}/x11/background_manager.cpp
|
|
|
|
${src_dir}/x11/connection.cpp
|
|
|
|
${src_dir}/x11/ewmh.cpp
|
|
|
|
${src_dir}/x11/extensions/composite.cpp
|
|
|
|
${src_dir}/x11/extensions/randr.cpp
|
|
|
|
${src_dir}/x11/icccm.cpp
|
|
|
|
${src_dir}/x11/registry.cpp
|
2022-10-31 22:05:23 +00:00
|
|
|
${src_dir}/x11/legacy_tray_manager.cpp
|
2022-01-22 19:35:37 +00:00
|
|
|
${src_dir}/x11/tray_client.cpp
|
|
|
|
${src_dir}/x11/tray_manager.cpp
|
|
|
|
${src_dir}/x11/window.cpp
|
|
|
|
${src_dir}/x11/winspec.cpp
|
|
|
|
${src_dir}/x11/xembed.cpp
|
|
|
|
|
|
|
|
$<$<BOOL:${ENABLE_ALSA}>:${ALSA_SOURCES}>
|
|
|
|
$<$<BOOL:${ENABLE_CURL}>:${GITHUB_SOURCES}>
|
|
|
|
$<$<BOOL:${ENABLE_I3}>:${I3_SOURCES}>
|
|
|
|
$<$<BOOL:${ENABLE_MPD}>:${MPD_SOURCES}>
|
|
|
|
$<$<BOOL:${ENABLE_NETWORK}>:${NETWORK_SOURCES}>
|
|
|
|
$<$<BOOL:${ENABLE_PULSEAUDIO}>:${PULSEAUDIO_SOURCES}>
|
|
|
|
$<$<BOOL:${WITH_XCURSOR}>:${XCURSOR_SOURCES}>
|
|
|
|
$<$<BOOL:${WITH_XKB}>:${XKB_SOURCES}>
|
|
|
|
$<$<BOOL:${WITH_XRM}>:${XRM_SOURCES}>
|
|
|
|
)
|
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# Target poly {{{
|
|
|
|
add_library(poly STATIC EXCLUDE_FROM_ALL ${POLY_SOURCES})
|
|
|
|
target_include_directories(poly PUBLIC ${includes_dir})
|
|
|
|
target_link_libraries(poly PUBLIC
|
|
|
|
Threads::Threads
|
|
|
|
Cairo::CairoFC
|
|
|
|
xpp
|
|
|
|
LibUV::LibUV
|
|
|
|
)
|
|
|
|
|
|
|
|
if (TARGET i3ipc++)
|
|
|
|
target_link_libraries(poly PUBLIC i3ipc++)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET ALSA::ALSA)
|
|
|
|
target_link_libraries(poly PUBLIC ALSA::ALSA)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET CURL::libcurl)
|
|
|
|
target_link_libraries(poly PUBLIC CURL::libcurl)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET LibMPDClient::LibMPDClient)
|
|
|
|
target_link_libraries(poly PUBLIC LibMPDClient::LibMPDClient)
|
2020-12-22 02:43:06 +00:00
|
|
|
endif()
|
2016-11-20 22:04:31 +00:00
|
|
|
|
2022-01-22 19:35:37 +00:00
|
|
|
if (TARGET LibNlGenl3::LibNlGenl3)
|
|
|
|
target_link_libraries(poly PUBLIC LibNlGenl3::LibNlGenl3)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET Libiw::Libiw)
|
|
|
|
target_link_libraries(poly PUBLIC Libiw::Libiw)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET LibPulse::LibPulse)
|
|
|
|
target_link_libraries(poly PUBLIC LibPulse::LibPulse)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET Xcb::RANDR)
|
|
|
|
target_link_libraries(poly PUBLIC Xcb::RANDR)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET Xcb::COMPOSITE)
|
|
|
|
target_link_libraries(poly PUBLIC Xcb::COMPOSITE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET Xcb::XKB)
|
|
|
|
target_link_libraries(poly PUBLIC Xcb::XKB)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET Xcb::CURSOR)
|
|
|
|
target_link_libraries(poly PUBLIC Xcb::CURSOR)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET Xcb::XRM)
|
|
|
|
target_link_libraries(poly PUBLIC Xcb::XRM)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (TARGET LibInotify::LibInotify)
|
|
|
|
target_link_libraries(poly PUBLIC LibInotify::LibInotify)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_compile_options(poly PUBLIC ${cxx_flags})
|
|
|
|
set_target_properties(poly PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libs)
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# Target: polybar {{{
|
|
|
|
if(BUILD_POLYBAR)
|
|
|
|
add_executable(polybar main.cpp)
|
|
|
|
target_link_libraries(polybar poly)
|
|
|
|
target_compile_options(polybar PUBLIC ${cxx_flags})
|
|
|
|
set_target_properties(polybar PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
|
|
|
|
install(TARGETS polybar
|
|
|
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
COMPONENT runtime)
|
|
|
|
endif()
|
|
|
|
# }}}
|
|
|
|
|
2017-01-26 16:17:02 +00:00
|
|
|
# Target: polybar-msg {{{
|
2020-12-22 02:43:06 +00:00
|
|
|
if(BUILD_POLYBAR_MSG)
|
2022-01-22 19:35:37 +00:00
|
|
|
add_executable(polybar-msg polybar-msg.cpp)
|
|
|
|
target_link_libraries(polybar-msg poly)
|
2019-06-12 00:02:27 +00:00
|
|
|
target_include_directories(polybar-msg PRIVATE ${includes_dir})
|
2021-07-11 12:11:58 +00:00
|
|
|
target_compile_options(polybar-msg PUBLIC ${cxx_flags})
|
2018-11-21 17:46:33 +00:00
|
|
|
|
|
|
|
install(TARGETS polybar-msg
|
|
|
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
COMPONENT runtime)
|
2017-01-10 01:09:27 +00:00
|
|
|
endif()
|
|
|
|
# }}}
|