fix(home): match wrapped waybar comm when killing bar on monitor change

`pkill -x waybar` matched only comm `waybar`, but the home-manager
wrapper launches the bar with comm `.waybar-wrapped` (arg[0] still
`waybar`), so the kill missed and left a stale bar drawing on the old
geometry after an unplug. Match both comms via an anchored ERE in both
the `monitor-hotplug` handler and `swapMonitors`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-22 19:16:44 +02:00
co-authored by Claude Opus 4.8
parent 102fb3c3c4
commit 38556c8839
2 changed files with 12 additions and 5 deletions
+7 -3
View File
@@ -40,10 +40,14 @@ let
"monitoradded>>"* | "monitorremoved>>"*)
sleep 1 # let Hyprland settle the new geometry
setbg # re-push wallpaper to all current outputs
${pkgs.procps}/bin/pkill -x waybar || true # relaunch waybar fresh (see comment)
# Anchored ERE matching `comm` (max 15 chars): the bar launched via the
# home-manager wrapper reports comm `.waybar-wrapped` (arg[0] is still
# `waybar`), so a bare `-x waybar` never matches it and leaves a stale bar.
wb='\.waybar-wrapped|waybar'
${pkgs.procps}/bin/pkill -x "$wb" || true # relaunch waybar fresh (see comment)
i=0
while [ $i -lt 6 ] && ${pkgs.procps}/bin/pgrep -x waybar >/dev/null; do sleep 0.3; i=$((i+1)); done
${pkgs.procps}/bin/pkill -9 -x waybar || true
while [ $i -lt 6 ] && ${pkgs.procps}/bin/pgrep -x "$wb" >/dev/null; do sleep 0.3; i=$((i+1)); done
${pkgs.procps}/bin/pkill -9 -x "$wb" || true
${hyprctl} dispatch exec waybar
;;
esac