diff --git a/features/scripts/utils/nomarchy-restart-waybar b/features/scripts/utils/nomarchy-restart-waybar index 041c848..0e4f690 100755 --- a/features/scripts/utils/nomarchy-restart-waybar +++ b/features/scripts/utils/nomarchy-restart-waybar @@ -1,13 +1,22 @@ #!/bin/bash -# Waybar is provided as a Home Manager user service -# (programs.waybar.systemd.enable = true), so the right way to restart it is -# via systemd. `pkill + uwsm-app` races with HM's sd-switch on theme changes -# and sometimes lands the new waybar without a full environment, producing -# the "wrong colors after theme switch" symptom. +# Reload waybar in place when it's already running. SIGUSR2 makes waybar +# re-read its config.jsonc and CSS (including @import-ed files like +# ~/.config/nomarchy/current/theme/waybar.css that theme-switch rewrites) +# without destroying its layer-shell surface. A full systemctl restart +# tears the surface down and creates a new one back-to-back, leaving a +# frame or two where Hyprland hasn't cleared the dead surface yet — that's +# the "old on top of new with artifacts" you see after a theme switch on +# the live ISO. +if pgrep -x waybar >/dev/null; then + exec pkill -SIGUSR2 -x waybar +fi -if systemctl --user list-unit-files waybar.service >/dev/null 2>&1; then - exec systemctl --user restart waybar.service +# Not running yet — start it. Prefer the HM systemd user unit +# (programs.waybar.systemd.enable = true). `systemctl cat` returns +# non-zero when the unit doesn't exist; `list-unit-files` does not. +if systemctl --user cat waybar.service >/dev/null 2>&1; then + exec systemctl --user start waybar.service fi # Fallback for systems where waybar isn't managed by systemd.