fix(nightlight): keep wlsunset alive when Waybar is absent

ExecStartPost signalled Waybar via `pkill -RTMIN+11 waybar`; with no Waybar
running (e.g. a quickshell-only session) pkill exits 1, which failed the unit
and — via Restart=on-failure — spun wlsunset in a ~3s restart loop that
flickered the screen and could not be switched off (stuck "activating").

Prefix the ExecStartPost with `-` so a missing Waybar is non-fatal. The
refresh signal still fires when Waybar is present.
This commit is contained in:
2026-07-05 10:09:26 +02:00
parent 33bb0a2576
commit a19ab8b5d8
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ Waybar toggle for wlsunset (Wayland-native blue light filter), persistent state
- Clicking the nightlight module in `group/brightness` toggles wlsunset on/off (`enable --now` / `disable --now`)
- State survives reboots (user-scope symlink in `~/.config/systemd/user/...wants/`)
- Active state shows 󰌵 in Catppuccin Yellow, inactive 󰌶 in the default text color
- Signal SIGRTMIN+11 for immediate Waybar refresh
- Signal SIGRTMIN+11 for immediate Waybar refresh — the `ExecStartPost` pkill has a leading `-` (`ExecStartPost=-/usr/bin/pkill …`) so a missing Waybar (e.g. a quickshell-only session) doesn't fail the unit. Without it, pkill's exit 1 trips `Restart=on-failure` and wlsunset loops, flickering the screen.
- Scripts: `moonarch-nightlight` (toggle), `moonarch-waybar-nightlight` (status JSON)
- **Important**: Never create a global-scope symlink at `/etc/systemd/user/...wants/wlsunset.service` — it overrides any user `disable` and makes the filter effectively impossible to turn off.
+4 -1
View File
@@ -12,7 +12,10 @@ Type=simple
# Give kanshi time to configure all outputs before wlsunset captures them
ExecStartPre=/bin/sleep 2
ExecStart=/usr/bin/wlsunset -T 6500 -t 5000 -S 00:00 -s 00:01
ExecStartPost=/usr/bin/pkill -RTMIN+11 waybar
# Refresh the waybar indicator if running; the leading '-' makes a missing waybar
# (e.g. quickshell-only session) non-fatal — otherwise pkill's exit 1 fails the unit
# and Restart=on-failure spins wlsunset in a gamma-flickering restart loop.
ExecStartPost=-/usr/bin/pkill -RTMIN+11 waybar
Restart=on-failure
RestartSec=3