Systemd Sleep Hook for sunsetr
This update adds a systemd sleep hook, fixes timezone display in simulation mode, and adds some other minor refinements.
When a laptop wakes from sleep (S3/S4 states), the systemd sleep hook:
- Detects the running sunsetr process
- Sends a SIGUSR2 signal
- This triggers immediate state recalculation, fixing the color temperature
Installation
AUR (sunsetr-bin)
Automatically installed during installation:
paru -S sunsetr-binAutomated Installation (Recommended)
Option 1: Using cargo-make (for source builds)
# Install cargo-make if you haven't already
cargo install cargo-make
# From the project root, install everything
cargo make install
# Or install just the sleep hook
cargo make install-sleep-hookOption 2: Using the shell script (for releases/packages)
# From the project root
sudo system-sleep/install.shManual Installation
# Copy the hook to systemd's sleep directory
sudo cp system-sleep/sunsetr-resume.sh /usr/lib/systemd/system-sleep/sunsetr-resume
# Make it executable
sudo chmod +x /usr/lib/systemd/system-sleep/sunsetr-resumeHow it works
The hook works regardless of how sunsetr is started:
- Via systemd service (
systemctl --user start sunsetr) - Manually from terminal (
sunsetr) - From a desktop environment's autostart
- Any other method
It uses pgrep to find running sunsetr processes and sends SIGUSR2 to each one, which triggers the existing reload mechanism in sunsetr.
Testing
To test if the hook is working:
- Start sunsetr
- Note the current color temperature
- Suspend your system (close laptop lid, or
systemctl suspend) - Wait a few seconds
- Resume the system
- Check journalctl for confirmation:
journalctl -t sunsetr-resume -n 5
You should see the color temperature update immediately upon resume instead of waiting for the next scheduled check.
Uninstallation
To remove everything (binary, service, and sleep hook):
cargo make uninstallOr to remove just the sleep hook manually:
sudo rm /usr/lib/systemd/system-sleep/sunsetr-resume