fix(waybar): SIGUSR2 reload to avoid surface-recreate ghost on theme switch
Theme-switching ran systemctl --user restart waybar.service, which tears down waybar's wayland layer-shell surface and creates a new one back-to-back. Hyprland needs a frame to clear the destroyed surface; the new instance attaches its surface immediately, so for a frame or two the old waybar pixels remain visible behind/under the new bar - the "artifacts and old colors on top of new" symptom most visible on the fresh compositor of the live ISO. Switch to SIGUSR2 reload, which makes waybar re-read config.jsonc and CSS (including @import-ed files like ~/.config/nomarchy/current/theme/ waybar.css that theme-switch rewrites) without destroying the surface. Full systemctl start is kept for the cold-start case. Drive-by: replace the `systemctl list-unit-files` presence check with `systemctl cat` - list-unit-files returns 0 even on no-match, so the old check would always pick the systemctl branch and never fall through to the pkill fallback on systems where waybar isn't a systemd unit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Waybar is provided as a Home Manager user service
|
# Reload waybar in place when it's already running. SIGUSR2 makes waybar
|
||||||
# (programs.waybar.systemd.enable = true), so the right way to restart it is
|
# re-read its config.jsonc and CSS (including @import-ed files like
|
||||||
# via systemd. `pkill + uwsm-app` races with HM's sd-switch on theme changes
|
# ~/.config/nomarchy/current/theme/waybar.css that theme-switch rewrites)
|
||||||
# and sometimes lands the new waybar without a full environment, producing
|
# without destroying its layer-shell surface. A full systemctl restart
|
||||||
# the "wrong colors after theme switch" symptom.
|
# 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
|
# Not running yet — start it. Prefer the HM systemd user unit
|
||||||
exec systemctl --user restart waybar.service
|
# (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
|
fi
|
||||||
|
|
||||||
# Fallback for systems where waybar isn't managed by systemd.
|
# Fallback for systems where waybar isn't managed by systemd.
|
||||||
|
|||||||
Reference in New Issue
Block a user