From: Volker Schlecht Subject: Re: [Fix] wayland/waybar To: ports , Landry Breuil , Matthieu Herrb Date: Fri, 17 Apr 2026 08:26:05 +0200 Here's a nicer (and hopefully upstreamable) version of that diff. On 2026-04-17 00:01, Volker Schlecht wrote: >Attached is a quality-of-life improvement for users of wayland/waybar >that if possible I would still like to sneak in for 7.9: > >waybar has the documented feature that you can toggle its visibility by sending >it SIGUSR1 and reload its configuration by sending SIGUSR2. > >However, someone sought to improve things for OpenBSD by helpfully defining >SIGRTMIN and SIGRTMAX in terms of SIGUSR1: > >https://github.com/Alexays/Waybar/blob/d808c00324618c35de30335ca6fd215f6d81860f/include/util/SafeSignal.hpp#L14 > >That has the unfortunate consequence that waybar handles SIGUSR1 and SIGUSR2 the >same way as it would handle SIGRTs on Linux, or in short: that functionality is >broken on OpenBSD. > >I patched things up to make SIGUSR handling work again. > >While testing that, I also noticed that the sndio module doesn't take very well >to being reloaded, and crashes or hangs in various exciting ways in those >situations - therefore I also adjusted the example configuration to replace the >sndio module by a few invocations of sndioctl(1). > >ok? Index: Makefile =================================================================== RCS file: /cvs/ports/wayland/waybar/Makefile,v diff -u -p -r1.4 Makefile --- Makefile 29 Mar 2026 12:01:55 -0000 1.4 +++ Makefile 17 Apr 2026 06:16:16 -0000 @@ -4,7 +4,7 @@ V = 0.15.0 DIST_TUPLE= github Alexays Waybar ${V} . PKGNAME= waybar-${V} -REVISION= 0 +REVISION= 1 CATEGORIES = wayland Index: patches/patch-include_util_SafeSignal_hpp =================================================================== RCS file: patches/patch-include_util_SafeSignal_hpp diff -N patches/patch-include_util_SafeSignal_hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-include_util_SafeSignal_hpp 17 Apr 2026 06:16:16 -0000 @@ -0,0 +1,15 @@ +Index: include/util/SafeSignal.hpp +--- include/util/SafeSignal.hpp.orig ++++ include/util/SafeSignal.hpp +@@ -11,11 +11,6 @@ + #include + #include + +-#ifdef __OpenBSD__ +-#define SIGRTMIN SIGUSR1 - 1 +-#define SIGRTMAX SIGUSR1 + 1 +-#endif +- + namespace waybar { + + /** Index: patches/patch-resources_config_jsonc =================================================================== RCS file: /cvs/ports/wayland/waybar/patches/patch-resources_config_jsonc,v diff -u -p -r1.3 patch-resources_config_jsonc --- patches/patch-resources_config_jsonc 29 Mar 2026 12:01:56 -0000 1.3 +++ patches/patch-resources_config_jsonc 17 Apr 2026 06:16:16 -0000 @@ -24,7 +24,7 @@ Index: resources/config.jsonc - "network", - "power-profiles-daemon", + //"mpd", -+ "sndio", ++ "custom/sndio", "cpu", "memory", - "temperature", @@ -67,7 +67,7 @@ Index: resources/config.jsonc "format-alt": "{:%Y-%m-%d}" }, "cpu": { -@@ -122,98 +111,30 @@ +@@ -122,98 +111,32 @@ "memory": { "format": "{}% " }, @@ -98,11 +98,13 @@ Index: resources/config.jsonc - // "format-good": "", // An empty format will hide the module - // "format-full": "", - "format-icons": ["", "", "", "", ""] -+ "sndio": { -+ "scroll-step": "1", -+ "format": "  {volume}% ", -+ "on-scroll-down": "sndioctl output.level=-0.01", -+ "on-scroll-up": "sndioctl output.level=+0.01" ++ "custom/sndio": { ++ "format": "  {}% ", ++ "interval": 10, ++ "exec": "if [ $(sndioctl -n output.mute) -eq 1 ]; then echo \"--\"; else sndioctl -n output.level | awk '{printf \"%.0f\\n\", $1 * 100}'; fi", ++ "on-click": "sndioctl output.mute=! > /dev/null", ++ "on-scroll-down": "sndioctl output.level=-0.01 > /dev/null", ++ "on-scroll-up": "sndioctl output.level=+0.01 > /dev/null" }, - "battery#bat2": { - "bat": "BAT2" Index: patches/patch-resources_style_css =================================================================== RCS file: /cvs/ports/wayland/waybar/patches/patch-resources_style_css,v diff -u -p -r1.2 patch-resources_style_css --- patches/patch-resources_style_css 29 Mar 2026 12:01:56 -0000 1.2 +++ patches/patch-resources_style_css 17 Apr 2026 06:16:16 -0000 @@ -49,11 +49,12 @@ Index: resources/style.css label:focus { background-color: #000000; } -@@ -203,6 +226,16 @@ label:focus { +@@ -203,6 +226,17 @@ label:focus { color: #2a5c45; } -+#sndio { ++#sndio, ++#custom-sndio { + background-color: #f1c40f; + color: #000; +} @@ -66,7 +67,7 @@ Index: resources/style.css #wireplumber { background-color: #fff0f5; color: #000000; -@@ -227,6 +260,10 @@ label:focus { +@@ -227,6 +261,10 @@ label:focus { } #temperature { Index: patches/patch-src_main_cpp =================================================================== RCS file: patches/patch-src_main_cpp diff -N patches/patch-src_main_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_main_cpp 17 Apr 2026 06:16:16 -0000 @@ -0,0 +1,30 @@ +Index: src/main.cpp +--- src/main.cpp.orig ++++ src/main.cpp +@@ -52,9 +52,11 @@ static void catchSignals(waybar::SafeSignal& sign + std::signal(SIGINT, writeSignalToPipe); + std::signal(SIGCHLD, writeSignalToPipe); + ++#ifdef SIGRTMIN + for (int sig = SIGRTMIN + 1; sig <= SIGRTMAX; ++sig) { + std::signal(sig, writeSignalToPipe); + } ++#endif + + while (true) { + int signum; +@@ -116,12 +118,14 @@ void handleUserSignal(int signal, bool& reload) { + // If this signal should restart or close the bar, this function will write + // `true` or `false`, respectively, into `reload`. + static void handleSignalMainThread(int signum, bool& reload) { ++#ifdef SIGRTMIN + if (signum >= SIGRTMIN + 1 && signum <= SIGRTMAX) { + for (auto& bar : waybar::Client::inst()->bars) { + bar->handleSignal(signum); + } + return; + } ++#endif + + switch (signum) { + case SIGUSR1: Index: patches/patch-src_modules_custom_cpp =================================================================== RCS file: patches/patch-src_modules_custom_cpp diff -N patches/patch-src_modules_custom_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_modules_custom_cpp 17 Apr 2026 06:16:16 -0000 @@ -0,0 +1,15 @@ +Index: src/modules/custom.cpp +--- src/modules/custom.cpp.orig ++++ src/modules/custom.cpp +@@ -136,9 +136,11 @@ void waybar::modules::Custom::waitingWorker() { + } + + void waybar::modules::Custom::refresh(int sig) { ++#ifdef SIGRTMIN + if (config_["signal"].isInt() && sig == SIGRTMIN + config_["signal"].asInt()) { + thread_.wake_up(); + } ++#endif + } + + void waybar::modules::Custom::handleEvent() { Index: patches/patch-src_modules_image_cpp =================================================================== RCS file: patches/patch-src_modules_image_cpp diff -N patches/patch-src_modules_image_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_modules_image_cpp 17 Apr 2026 06:16:16 -0000 @@ -0,0 +1,15 @@ +Index: src/modules/image.cpp +--- src/modules/image.cpp.orig ++++ src/modules/image.cpp +@@ -41,9 +41,11 @@ void waybar::modules::Image::delayWorker() { + } + + void waybar::modules::Image::refresh(int sig) { ++#ifdef SIGRTMIN + if (config_["signal"].isInt() && sig == SIGRTMIN + config_["signal"].asInt()) { + thread_.wake_up(); + } ++#endif + } + + auto waybar::modules::Image::update() -> void {