github psi4j/sunsetr v0.11.0
v0.11.0 IPC and Status Command!

15 hours ago

Sunsetr v0.11.0

This release brings significant improvements to Sunsetr's command-line interface, state monitoring capabilities, and reliability. v0.11.0 focuses on giving users better control over the application lifecycle and fixing critical timing issues that affected transitions.

New Commands

status command

The status command returns data using the new IPC. Running without flags returns a one-shot output containing runtime state details. Using the --follow flag returns a continuous human-readable stream, and using the --json flag returns output in JSON for scripting and interoperation.

Usage:

sunsetr status          # Human-readable output
sunsetr status --json   # JSON output for scripting
sunsetr status --follow # Continuous monitoring
sunsetr status -j -f    # Continuous JSON monitoring

Example output:

❯ sunsetr status
 Active preset: default
Current period: Night 
         State: stable
   Temperature: 3300K
         Gamma: 90.0%
   Next period: 06:42:50 (in 11h47m)

Related: #11 #24


stop command

Gracefully terminate a running Sunsetr instance with verification.

Usage:

sunsetr stop

restart command

Recreate the backend and reload configuration with a clean stop-wait-start sequence.

Usage:

sunsetr restart              # Normal restart with smooth shutdown
sunsetr restart --instant    # Skip smooth shutdown transition
sunsetr restart --background # Restart in background mode
  • Clean stop-wait-start sequence (replaces complex in-process backend recreation)
  • --instant flag to skip smooth shutdown transitions
  • Useful for recovering from DPMS issues or compositor switches
  • Compatible with --background flag

Replaces: The deprecated reload command (see Breaking Changes)

Related: #25


--background flag

Run Sunsetr as a background process without occupying your terminal.

Usage:

sunsetr --background          # Start in background
sunsetr restart --background  # Restart in background

IPC for sharing internal state

sunsetr now provides a Unix socket-based IPC for real-time integration with external applications like status bars (waybar, quickshell, eww), notification systems, and custom scripts. The IPC socket is automatically created when sunsetr starts:

$XDG_RUNTIME_DIR/sunsetr/ipc.sock
# Typically: /run/user/1000/sunsetr/ipc.sock

The IPC system broadcasts three types of events in JSON format:

  1. StateApplied: Emitted whenever the display state changes (every update interval, config reloads, preset changes)
{
  "event_type": "state_applied",
  "active_preset": "default",
  "period": "sunset",
  "state": "transitioning",
  "progress": 0.45,
  "current_temp": 5100,
  "current_gamma": 95.0,
  "target_temp": 3300,
  "target_gamma": 90.0,
  "next_period": "2025-01-15T19:00:00-06:00"
}

Fields:

  • event_type: Always "state_applied"
  • active_preset: Name of the currently active preset (or "default")
  • period: Current period - "day", "night", "sunset", "sunrise", or "static"
  • state: Period type for categorization - "stable", "transitioning", or "static"
  • progress: Transition progress (0.0 to 1.0), only present during transitions
  • current_temp: Currently applied temperature in Kelvin
  • current_gamma: Currently applied gamma as percentage
  • target_temp: Target temperature (only present during transitions)
  • target_gamma: Target gamma (only present during transitions)
  • next_period: ISO 8601 timestamp of next scheduled period (null for static mode)
  1. PeriodChanged: Emitted only during automatic time-based period transitions
{
  "event_type": "period_changed",
  "from_period": "day",
  "to_period": "sunset"
}

Fields:

  • event_type: Always "period_changed"
  • from_period: The period we're transitioning from
  • to_period: The period we're transitioning to
  1. PresetChanged: Emitted when switching presets
{
  "event_type": "preset_changed",
  "from_preset": null,
  "to_preset": "gaming",
  "target_period": "static",
  "target_temp": 4700,
  "target_gamma": 100.0
}

Fields:

  • event_type: Always "preset_changed"
  • from_preset: Previous preset name (null if transitioning from default config)
  • to_preset: New preset name (null if transitioning to default config) (New only on latest git)
  • target_period: Target period after preset change - "day", "night", "sunset", "sunrise", or "static"
  • target_temp: Target temperature in Kelvin
  • target_gamma: Target gamma as percentage

e.g.:

Recommended: Real-time updates with dynamic icons
(This particular example only works on latest git as of right now due to the added target_period field)

// ~/.config/waybar/config
{
  "custom/sunsetr": {
    "exec": "sunsetr status --json --follow | jq --unbuffered --compact-output 'if .event_type == \"preset_changed\" then {text: \"\\(.target_temp)K\", alt: .target_period, tooltip: \"Preset: \\(.to_preset // \"default\")\\nTarget: \\(.target_temp)K @ \\(.target_gamma)%\"} elif .event_type == \"state_applied\" then {text: \"\\(.current_temp)K\", alt: .period, tooltip: \"Period: \\(.period)\\nTemp: \\(.current_temp)K @ \\(.current_gamma)%\"} else empty end'",
    "return-type": "json",
    "format": "{icon} {text}",
    "format-icons": {
      "day": "󰖨",
      "night": "",
      "sunset": "󰖛",
      "sunrise": "󰖜",
      "static": "󰋙"
    },
    "on-click": "sunsetr preset day"
  }
}

related: #11 #24


Bug Fixes

  • Period transitions now happen precisely on time instead of one update_interval after start time
  • Time jumps (manual adjustments, NTP sync, sleep/resume) now immediately apply correct temperature/gamma values
  • DST changes are now correctly accounted for in status output and transition schedules
  • Zombie processes from previous sessions are automatically detected and cleaned up after logout/reboot
  • Test mode now properly prevents concurrent regular instances from starting
  • Preset switching no longer incorrectly reverts to default configuration or skips period announcements
  • Command flags (--config on set and get commands) now work correctly with flexible placement

Breaking Changes

The reload command has been deprecated and removed in favor of:

  1. Automatic hot configuration reloading - Config changes are automatically detected
  2. restart command - For full re-initialization when needed

Migration:

# Old way:
sunsetr reload

# New way:
sunsetr restart --background  # Or just edit config - it auto-reloads!

With automatic hot configuration reloading, the reload command became redundant. The restart command provides a more robust solution for cases requiring full re-initialization. Fully removed in this release. Using sunsetr reload will show a deprecation warning and map to restart --background.


Other Improvements

  • Extended gamma range Gamma range extended from 100% to 200%, matching Hyprsunset's capabilities.) (#26)
  • Architectural improvements: Cleaner state management with immutable patterns and centralized context
  • Code quality: Improved documentation, error messages, and terminal signal handling
  • Testing: Extended gamma range tests and property-based configuration validation
  • Data accuracy: Fixed country/coordinate data and added Asia/Kolkata timezone

New AUR Packages


Upgrade Notes

  1. Config compatibility: All existing configurations remain compatible
  2. Gamma range: You can now use values up to 200% if desired
  3. Command changes: Replace any reload commands with restart or rely on automatic hot reloading
  4. New commands: Try out status, stop, and restart for better process management

💛 Special thanks to:


Full Changelog

See the commit history for complete details.

Don't miss a new sunsetr release

NewReleases is sending notifications on new releases.