Files
Nomarchy/features/scripts/utils/nomarchy-restart-waybar
Bernardo Magri 386da51178 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>
2026-04-30 19:24:25 +01:00

24 lines
1007 B
Bash
Executable File

#!/bin/bash
# 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
# 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.
nomarchy-restart-app waybar