From 8c70513a248fb9c22ff37d14e9a06b983099ab71 Mon Sep 17 00:00:00 2001 From: nullobsi Date: Sun, 31 Jan 2021 13:58:41 -0800 Subject: [PATCH 1/4] add common `align` config property to set text alignment add fixed-length property to set the fixed width of the label --- src/ALabel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 9371a0e7..4d15cc17 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -28,6 +28,15 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st label_.set_single_line_mode(true); } + if (config_["fixed-length"].isUInt()) { + label_.set_width_chars(config_["fixed-length"].asUInt()); + } + + if (config_["align"].isDouble()) { + auto align = config_["align"].asFloat(); + label_.set_xalign(align); + } + if (config_["rotate"].isUInt()) { label_.set_angle(config["rotate"].asUInt()); } From c8d7b6fa92ea006d35b4c425fb38fb8fe83f7d98 Mon Sep 17 00:00:00 2001 From: nullobsi Date: Sun, 31 Jan 2021 14:03:49 -0800 Subject: [PATCH 2/4] rename fixed-length to min-length --- src/ALabel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 4d15cc17..ed5740a2 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -20,7 +20,7 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st } event_box_.add(label_); if (config_["max-length"].isUInt()) { - label_.set_max_width_chars(config_["max-length"].asUInt()); + label_.set_max_width_chars(config_["max-length"].asInt()); label_.set_ellipsize(Pango::EllipsizeMode::ELLIPSIZE_END); label_.set_single_line_mode(true); } else if (ellipsize && label_.get_max_width_chars() == -1) { @@ -28,8 +28,8 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st label_.set_single_line_mode(true); } - if (config_["fixed-length"].isUInt()) { - label_.set_width_chars(config_["fixed-length"].asUInt()); + if (config_["min-length"].isUInt()) { + label_.set_width_chars(config_["min-length"].asUInt()); } if (config_["align"].isDouble()) { From 72cd753c0259f695adc4bf372048256bc403a47d Mon Sep 17 00:00:00 2001 From: nullobsi Date: Mon, 1 Feb 2021 01:44:51 -0800 Subject: [PATCH 3/4] align should use rotate property --- src/ALabel.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ALabel.cpp b/src/ALabel.cpp index ed5740a2..8d9c9b41 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -32,14 +32,24 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st label_.set_width_chars(config_["min-length"].asUInt()); } - if (config_["align"].isDouble()) { - auto align = config_["align"].asFloat(); - label_.set_xalign(align); - } + uint rotate = 0; if (config_["rotate"].isUInt()) { - label_.set_angle(config["rotate"].asUInt()); + rotate = config["rotate"].asUInt(); + label_.set_angle(rotate); } + + if (config_["align"].isDouble()) { + auto align = config_["align"].asFloat(); + if (rotate == 90 || rotate == 270) { + label_.set_yalign(align); + } else { + label_.set_xalign(align); + } + + } + + } auto ALabel::update() -> void { From 97f7050d7defb4dc3e23a1709ce063dbfaa38d9f Mon Sep 17 00:00:00 2001 From: nullobsi Date: Mon, 1 Feb 2021 08:34:51 -0800 Subject: [PATCH 4/4] Update man pages --- man/waybar-backlight.5.scd | 8 ++++++++ man/waybar-battery.5.scd | 8 ++++++++ man/waybar-bluetooth.5.scd | 8 ++++++++ man/waybar-clock.5.scd | 8 ++++++++ man/waybar-cpu.5.scd | 8 ++++++++ man/waybar-custom.5.scd | 8 ++++++++ man/waybar-disk.5.scd | 8 ++++++++ man/waybar-idle-inhibitor.5.scd | 8 ++++++++ man/waybar-memory.5.scd | 8 ++++++++ man/waybar-mpd.5.scd | 8 ++++++++ man/waybar-network.5.scd | 8 ++++++++ man/waybar-pulseaudio.5.scd | 8 ++++++++ man/waybar-sndio.5.scd | 8 ++++++++ man/waybar-sway-language.5.scd | 8 ++++++++ man/waybar-sway-mode.5.scd | 8 ++++++++ man/waybar-sway-window.5.scd | 8 ++++++++ man/waybar-temperature.5.scd | 8 ++++++++ 17 files changed, 136 insertions(+) diff --git a/man/waybar-backlight.5.scd b/man/waybar-backlight.5.scd index e6116e3e..d14e4f24 100644 --- a/man/waybar-backlight.5.scd +++ b/man/waybar-backlight.5.scd @@ -24,6 +24,14 @@ The *backlight* module displays the current backlight level. typeof: integer ++ The maximum length in characters the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *rotate*: ++ typeof: integer ++ Positive value to rotate the text label. diff --git a/man/waybar-battery.5.scd b/man/waybar-battery.5.scd index a4650cd6..48c2ee19 100644 --- a/man/waybar-battery.5.scd +++ b/man/waybar-battery.5.scd @@ -55,6 +55,14 @@ The *battery* module displays the current capacity and state (eg. charging) of y typeof: integer++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *rotate*: ++ typeof: integer++ Positive value to rotate the text label. diff --git a/man/waybar-bluetooth.5.scd b/man/waybar-bluetooth.5.scd index 5d7d7dd5..0cd9386a 100644 --- a/man/waybar-bluetooth.5.scd +++ b/man/waybar-bluetooth.5.scd @@ -35,6 +35,14 @@ Addressed by *bluetooth* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-clock.5.scd b/man/waybar-clock.5.scd index 9f36c435..28688ee9 100644 --- a/man/waybar-clock.5.scd +++ b/man/waybar-clock.5.scd @@ -45,6 +45,14 @@ The *clock* module displays the current date and time. typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *rotate*: ++ typeof: integer ++ Positive value to rotate the text label. diff --git a/man/waybar-cpu.5.scd b/man/waybar-cpu.5.scd index cb83134f..c8b12e26 100644 --- a/man/waybar-cpu.5.scd +++ b/man/waybar-cpu.5.scd @@ -24,6 +24,14 @@ The *cpu* module displays the current cpu utilization. typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *rotate*: ++ typeof: integer ++ Positive value to rotate the text label. diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index 3e820c63..8f9dcfaf 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -67,6 +67,14 @@ Addressed by *custom/* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-disk.5.scd b/man/waybar-disk.5.scd index 431d7c8f..58797141 100644 --- a/man/waybar-disk.5.scd +++ b/man/waybar-disk.5.scd @@ -39,6 +39,14 @@ Addressed by *disk* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-idle-inhibitor.5.scd b/man/waybar-idle-inhibitor.5.scd index 9d231d86..0b0bdd03 100644 --- a/man/waybar-idle-inhibitor.5.scd +++ b/man/waybar-idle-inhibitor.5.scd @@ -27,6 +27,14 @@ screensaving, also known as "presentation mode". typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. A click also toggles the state diff --git a/man/waybar-memory.5.scd b/man/waybar-memory.5.scd index 81c62165..3ff4c35b 100644 --- a/man/waybar-memory.5.scd +++ b/man/waybar-memory.5.scd @@ -34,6 +34,14 @@ Addressed by *memory* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-mpd.5.scd b/man/waybar-mpd.5.scd index 8c33c624..5bbc00a7 100644 --- a/man/waybar-mpd.5.scd +++ b/man/waybar-mpd.5.scd @@ -81,6 +81,14 @@ Addressed by *mpd* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index ab459ae0..f274881e 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -64,6 +64,14 @@ Addressed by *network* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-pulseaudio.5.scd b/man/waybar-pulseaudio.5.scd index c3f50e0b..d894290f 100644 --- a/man/waybar-pulseaudio.5.scd +++ b/man/waybar-pulseaudio.5.scd @@ -50,6 +50,14 @@ Additionally you can control the volume by scrolling *up* or *down* while the cu typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *scroll-step*: ++ typeof: float ++ default: 1.0 ++ diff --git a/man/waybar-sndio.5.scd b/man/waybar-sndio.5.scd index a61c3325..90a73f48 100644 --- a/man/waybar-sndio.5.scd +++ b/man/waybar-sndio.5.scd @@ -26,6 +26,14 @@ cursor is over the module, and clicking on the module toggles mute. typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *scroll-step*: ++ typeof: int ++ default: 5 ++ diff --git a/man/waybar-sway-language.5.scd b/man/waybar-sway-language.5.scd index a288cca9..769924f0 100644 --- a/man/waybar-sway-language.5.scd +++ b/man/waybar-sway-language.5.scd @@ -25,6 +25,14 @@ Addressed by *sway/language* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-sway-mode.5.scd b/man/waybar-sway-mode.5.scd index 958a1edb..b8b59cd3 100644 --- a/man/waybar-sway-mode.5.scd +++ b/man/waybar-sway-mode.5.scd @@ -25,6 +25,14 @@ Addressed by *sway/mode* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-sway-window.5.scd b/man/waybar-sway-window.5.scd index 4863a76c..40250e6f 100644 --- a/man/waybar-sway-window.5.scd +++ b/man/waybar-sway-window.5.scd @@ -25,6 +25,14 @@ Addressed by *sway/window* typeof: integer ++ The maximum length in character the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when clicked on the module. diff --git a/man/waybar-temperature.5.scd b/man/waybar-temperature.5.scd index 7810a59b..8d11e517 100644 --- a/man/waybar-temperature.5.scd +++ b/man/waybar-temperature.5.scd @@ -63,6 +63,14 @@ Addressed by *temperature* typeof: integer ++ The maximum length in characters the module should display. +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + *on-click*: ++ typeof: string ++ Command to execute when you clicked on the module.