feat: manage wlsunset via systemd user service
All checks were successful
Update PKGBUILD version / update-pkgver (push) Successful in 4s

Move nightlight from niri spawn-at-startup to a systemd user service
with After=kanshi.service to ensure all outputs are configured before
wlsunset starts. Toggle now uses enable/disable --now for persistent
state across reboots.
This commit is contained in:
nevaforget 2026-04-14 17:42:24 +02:00
parent 9bc753e092
commit 0433f08f08
8 changed files with 34 additions and 13 deletions

View File

@ -20,9 +20,10 @@ Laptops mit `charge_control_end_threshold`-Support (ThinkPad, Framework, etc.) e
## Nightlight (Blaufilter)
Waybar-Toggle für wlsunset (Wayland-nativer Blaufilter):
- `wlsunset` startet per Niri-Autostart mit fester Nacht-Temperatur (5000K)
- Klick auf das Nightlight-Modul in `group/brightness` toggled wlsunset an/aus (kill/restart)
Waybar-Toggle für wlsunset (Wayland-nativer Blaufilter), persistenter Zustand via systemd:
- `wlsunset.service` (systemd User-Service) mit `After=kanshi.service` — startet erst wenn alle Outputs konfiguriert sind
- Klick auf das Nightlight-Modul in `group/brightness` toggled wlsunset an/aus (`enable --now` / `disable --now`)
- Zustand überlebt Reboots (enabled/disabled bleibt bestehen)
- Aktiver Zustand zeigt 󰌵 in Catppuccin Yellow, inaktiv 󰌶 in Standard-Textfarbe
- Signal SIGRTMIN+11 für sofortiges Waybar-Refresh
- Scripts: `moonarch-nightlight` (Toggle), `moonarch-waybar-nightlight` (Status-JSON)

View File

@ -1,12 +1,11 @@
#!/bin/bash
# ABOUTME: Toggles wlsunset night light on/off.
# ABOUTME: Kills or restarts wlsunset process, signals waybar for refresh.
# ABOUTME: Toggles wlsunset night light on/off via systemd user service.
# ABOUTME: Persists state across reboots (enable/disable), signals waybar for refresh.
if pgrep -x wlsunset > /dev/null; then
pkill -x wlsunset
if systemctl --user is-active --quiet wlsunset; then
systemctl --user disable --now wlsunset
else
wlsunset -T 6500 -t 5000 -S 00:00 -s 00:01 &
disown
systemctl --user enable --now wlsunset
fi
pkill -RTMIN+11 waybar

View File

@ -1,8 +1,8 @@
#!/bin/bash
# ABOUTME: Outputs JSON status for waybar nightlight module.
# ABOUTME: Shows warm icon when wlsunset is active, cool icon when off.
# ABOUTME: Checks wlsunset systemd service, shows warm icon when active.
if pgrep -x wlsunset > /dev/null; then
if systemctl --user is-active --quiet wlsunset; then
jq -nc '{text: "󰌵", alt: "on", tooltip: "Nightlight: An (5000K)", class: "on"}'
else
jq -nc '{text: "󰌶", alt: "off", tooltip: "Nightlight: Aus", class: "off"}'

View File

@ -0,0 +1,19 @@
# ABOUTME: systemd user service for wlsunset night light (blue light filter).
# ABOUTME: Starts after kanshi to ensure all outputs are configured.
[Unit]
Description=Wlsunset night light (blue light filter)
Documentation=man:wlsunset(1)
PartOf=graphical-session.target
After=graphical-session.target kanshi.service
[Service]
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
Restart=on-failure
RestartSec=3
[Install]
WantedBy=graphical-session.target

View File

@ -86,7 +86,7 @@ spawn-at-startup "nm-applet" "--indicator"
spawn-sh-at-startup "waypaper --restore"
// spawn-sh-at-startup "nemo . &> /dev/null &"
spawn-sh-at-startup "foot --server"
spawn-at-startup "wlsunset" "-T" "6500" "-t" "5000" "-S" "00:00" "-s" "00:01"
// wlsunset is managed via systemd user service (wlsunset.service)
// Clipboard history managed by cliphist.service (systemd user service)
hotkey-overlay {

View File

@ -178,7 +178,7 @@ section "User Services"
if [[ $EUID -eq 0 ]]; then
warn "Running as root — skipping user service checks"
else
for svc in kanshi stasis cliphist-text cliphist-image; do
for svc in kanshi wlsunset stasis cliphist-text cliphist-image; do
check_user_service "$svc"
done
fi

View File

@ -124,6 +124,7 @@ fi
log "Enabling systemd user services..."
USER_SERVICES=(
"kanshi"
"wlsunset"
"stasis"
"cliphist-text"
"cliphist-image"

View File

@ -345,6 +345,7 @@ echo "source /etc/zsh/zshrc.moonarch" >> "$HOME/.zshrc"
log "Enabling systemd user services..."
USER_SERVICES=(
"kanshi"
"wlsunset"
"stasis"
"cliphist-text"
"cliphist-image"