From 76941c55b7fb6fd06164e39e2ce3292e620a4423 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Sun, 19 Jul 2026 11:04:08 +0100 Subject: [PATCH] =?UTF-8?q?fix(waybar):=20bar=20pokes=20missed=20the=20wra?= =?UTF-8?q?pped=20process=20=E2=80=94=20switches=20never=20touched=20the?= =?UTF-8?q?=20bar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nixpkgs wraps waybar, so the running comm is `.waybar-wrapped`: `pkill -x waybar` (state-sync restart/SIGUSR2 branches, tz-watch, updates) matched nothing — a theme switch neither restarted nor reloaded the bar, which then kept the gtk.css of whatever theme it started under (the stale workspace-digit colors reported 2026-07-18; companion gtk fix in the next commit). The unanchored pokes (recording, airplane, theme-shot) had the opposite bug: `waybar` substring-matches the supervisor's `nomarchy-waybar` comm too, and an unhandled RTMIN terminates its bash — the pokes were killing the crash guard. All seven sites now use `pkill … -x 'waybar|\.waybar-wrapped'`. state-sync 0.5.1 → 0.5.2. Verified live on Newton (V3-grade): new pattern restarts the bar under the supervisor (fresh pid, supervisor alive); RTMIN+10 poke reaches the bar, supervisor survives. V0 `nix flake check --no-build` + py_compile; V1 HM generation + system toplevel build. Co-Authored-By: Claude Fable 5 --- modules/home/recording.nix | 5 ++++- modules/home/timezone.nix | 3 ++- modules/home/updates.nix | 3 ++- modules/home/waybar.nix | 7 ++++--- pkgs/nomarchy-airplane/default.nix | 5 ++++- pkgs/nomarchy-state-sync/default.nix | 2 +- pkgs/nomarchy-state-sync/nomarchy-state-sync.py | 13 +++++++++++-- tools/theme-shot.nix | 2 +- 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/modules/home/recording.nix b/modules/home/recording.nix index a23624c..7d8520a 100644 --- a/modules/home/recording.nix +++ b/modules/home/recording.nix @@ -18,7 +18,10 @@ lib.mkIf config.nomarchy.rofi.enable { filefile="$run/nomarchy-record.file" alive() { [ -f "$pidfile" ] && kill -0 "$(cat "$pidfile")" 2>/dev/null; } - poke_bar() { pkill -RTMIN+8 waybar 2>/dev/null || true; } + # -x, both comm names: nixpkgs wraps the binary as `.waybar-wrapped`, + # and an unanchored `waybar` also matches (and kills) the + # nomarchy-waybar supervisor, whose bash dies on an unhandled RTMIN. + poke_bar() { pkill -RTMIN+8 -x 'waybar|\.waybar-wrapped' 2>/dev/null || true; } case "''${1:-}" in start) diff --git a/modules/home/timezone.nix b/modules/home/timezone.nix index 93f5ab8..59912df 100644 --- a/modules/home/timezone.nix +++ b/modules/home/timezone.nix @@ -24,7 +24,8 @@ let cur=$(${pkgs.systemd}/bin/timedatectl show -p Timezone --value 2>/dev/null || true) [ "$cur" = "$last" ] && continue last=$cur - ${pkgs.procps}/bin/pkill -SIGUSR2 -x waybar 2>/dev/null || true + # Both comm names: nixpkgs wraps the binary as `.waybar-wrapped`. + ${pkgs.procps}/bin/pkill -SIGUSR2 -x 'waybar|\.waybar-wrapped' 2>/dev/null || true done ''; in diff --git a/modules/home/updates.nix b/modules/home/updates.nix index f301485..2aa7f0b 100644 --- a/modules/home/updates.nix +++ b/modules/home/updates.nix @@ -71,7 +71,8 @@ let echo 0 } - refresh_bar() { ${pkgs.procps}/bin/pkill -RTMIN+9 -x waybar 2>/dev/null || true; } + # Both comm names: nixpkgs wraps the binary as `.waybar-wrapped`. + refresh_bar() { ${pkgs.procps}/bin/pkill -RTMIN+9 -x 'waybar|\.waybar-wrapped' 2>/dev/null || true; } case "''${1:-status}" in check) diff --git a/modules/home/waybar.nix b/modules/home/waybar.nix index 146724c..c8fac82 100644 --- a/modules/home/waybar.nix +++ b/modules/home/waybar.nix @@ -36,9 +36,10 @@ let # Waybar supervisor — exec-once has no restart, so a crashed bar used to # leave the session bar-less until relogin (seen on hardware: a theme # switch crashed waybar mid-reload). Respawns on ANY exit — a plain - # `pkill -x waybar` is now a clean restart, which nomarchy-state-sync - # uses instead of the crash-prone in-place SIGUSR2 reload when it sees - # this supervisor running. Crash-loop guard: 5 exits within 10s of + # `pkill -x 'waybar|\.waybar-wrapped'` (nixpkgs wraps the binary, so + # the comm is `.waybar-wrapped`) is now a clean restart, which + # nomarchy-state-sync uses instead of the crash-prone in-place SIGUSR2 + # reload when it sees this supervisor running. Crash-loop guard: 5 exits within 10s of # their start → give up with a critical notification instead of # spinning. Stop the bar for real: pkill -f nomarchy-waybar (TERM is # trapped to take the child down too). diff --git a/pkgs/nomarchy-airplane/default.nix b/pkgs/nomarchy-airplane/default.nix index 3c53904..212226f 100644 --- a/pkgs/nomarchy-airplane/default.nix +++ b/pkgs/nomarchy-airplane/default.nix @@ -22,8 +22,11 @@ writeShellScriptBin "nomarchy-airplane" '' networkmanager util-linux bluez coreutils gnugrep gawk libnotify procps ]} + # -x, both comm names: nixpkgs wraps the binary as `.waybar-wrapped`, + # and an unanchored `waybar` also matches (and kills) the + # nomarchy-waybar supervisor, whose bash dies on an unhandled RTMIN. poke_bar() { - pkill -RTMIN+11 waybar 2>/dev/null || true + pkill -RTMIN+11 -x 'waybar|\.waybar-wrapped' 2>/dev/null || true } wifi_enabled() { diff --git a/pkgs/nomarchy-state-sync/default.nix b/pkgs/nomarchy-state-sync/default.nix index eadc837..e58b6ce 100644 --- a/pkgs/nomarchy-state-sync/default.nix +++ b/pkgs/nomarchy-state-sync/default.nix @@ -16,7 +16,7 @@ stdenvNoCC.mkDerivation { pname = "nomarchy-state-sync"; - version = "0.5.1"; + version = "0.5.2"; src = ./.; diff --git a/pkgs/nomarchy-state-sync/nomarchy-state-sync.py b/pkgs/nomarchy-state-sync/nomarchy-state-sync.py index a338938..94c7737 100644 --- a/pkgs/nomarchy-state-sync/nomarchy-state-sync.py +++ b/pkgs/nomarchy-state-sync/nomarchy-state-sync.py @@ -447,14 +447,23 @@ def run_switch() -> None: # reload_style_on_change while the symlinks flip), so prefer the # restart whenever the supervisor is there to catch it; fall back to # SIGUSR2 for unsupervised/custom bars. No-ops if nothing is running. + # The pattern matches both comm names: nixpkgs wraps the binary, so + # the process is `.waybar-wrapped` — a bare `pkill -x waybar` matched + # nothing, theme switches never touched the bar, and it kept the + # gtk.css of whatever theme it was started under (the 2026-07-19 + # stale-digit-color bug). Keep -x: unanchored `waybar` also matches + # the supervisor's own `nomarchy-waybar` comm and would kill it. if shutil.which("pkill"): supervised = subprocess.run( ["pgrep", "-f", "nomarchy-waybar"], capture_output=True ).returncode == 0 if supervised: - subprocess.run(["pkill", "-x", "waybar"], check=False) + subprocess.run(["pkill", "-x", r"waybar|\.waybar-wrapped"], check=False) else: - subprocess.run(["pkill", "--signal", "SIGUSR2", "-x", "waybar"], check=False) + subprocess.run( + ["pkill", "--signal", "SIGUSR2", "-x", r"waybar|\.waybar-wrapped"], + check=False, + ) # ─── Theme assets (wallpapers) ──────────────────────────────────────────── diff --git a/tools/theme-shot.nix b/tools/theme-shot.nix index 7e6b467..f17cfcb 100644 --- a/tools/theme-shot.nix +++ b/tools/theme-shot.nix @@ -79,7 +79,7 @@ pkgs.testers.runNixOSTest { machine.succeed("grep -q 'theme\\[main_bg\\]' /home/nomarchy/.config/btop/themes/nomarchy.theme") # Poke custom/doctor (signal 10) so a first-poll miss at session start # doesn't leave the tripwire blank for the full 300s interval. - machine.execute("su - nomarchy -c 'pkill -RTMIN+10 waybar' >/dev/null 2>&1 || true") + machine.execute("su - nomarchy -c \"pkill -RTMIN+10 -x 'waybar|\\.waybar-wrapped'\" >/dev/null 2>&1 || true") machine.sleep(3) # Park the cursor in the bottom-right corner so it doesn't sit in the # middle of the desktop shot (that frame doubles as the theme-picker