github psi4j/sunsetr v0.7.3

latest releases: v0.10.0, v0.9.0, v0.8.0...
2 months ago

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:

  1. Detects the running sunsetr process
  2. Sends a SIGUSR2 signal
  3. This triggers immediate state recalculation, fixing the color temperature

Installation

AUR (sunsetr-bin)

Automatically installed during installation:

paru -S sunsetr-bin

Automated 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-hook

Option 2: Using the shell script (for releases/packages)

# From the project root
sudo system-sleep/install.sh

Manual 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-resume

How 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:

  1. Start sunsetr
  2. Note the current color temperature
  3. Suspend your system (close laptop lid, or systemctl suspend)
  4. Wait a few seconds
  5. Resume the system
  6. 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 uninstall

Or to remove just the sleep hook manually:

sudo rm /usr/lib/systemd/system-sleep/sunsetr-resume

Don't miss a new sunsetr release

NewReleases is sending notifications on new releases.