Index | Thread | Search

From:
Landry Breuil <landry@openbsd.org>
Subject:
Re: [Fix] wayland/waybar
To:
Volker Schlecht <openbsd-ports@schlecht.dev>
Cc:
ports <ports@openbsd.org>, Matthieu Herrb <matthieu@herrb.eu>
Date:
Fri, 17 Apr 2026 09:47:53 +0200

Download raw body.

Thread
Le Fri, Apr 17, 2026 at 08:26:05AM +0200, Volker Schlecht a écrit :
> Here's a nicer (and hopefully upstreamable) version of that diff.

i dont really understand this signal whack-a-mole, but when you upstream
it cc the user that did add them in
https://github.com/Alexays/Waybar/pull/4278 maybe ?

the sndio thing looks ok, havent tested it.
> + #include <type_traits>
> + #include <utility>
> + 
> +-#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<int>& 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 {