github psi4j/sunsetr v0.9.0
v0.9.0 Presets and Hot Reloading

latest release: v0.10.0
one month ago

Sunsetr v0.9.0

This release brings major improvements to user experience with preset management, smooth transitions, hot configuration reloading, and a new static mode. The codebase has undergone significant refactoring to improve maintainability and reliability.

New Features

Static Mode

  • New static transition mode that maintains constant temperature and gamma values
  • Perfect for when you need consistent values without time-based transitions
  • Night and day configuration fields are ignored when using static mode
  • Time related configuration fields are also ignored when using static mode
  • Fully integrated with the preset system for quick static value switching

Usage: Configure in your sunsetr.toml:

# Static mode - constant values, no transitions
transition_mode = "static"
static_temp = 5000       # Constant color temperature (1000-20000) Kelvin
static_gamma = 90        # Constant gamma percentage (10-100%)

# Note: sunset/sunrise/day/night values not needed for static mode

Combine with presets for quick static toggles

Preset Management System

  • New preset command allows quick switching between different configuration presets stored in a directory hierarchy
  • Seamlessly toggle between different profiles (e.g., default, gaming, weekend, day)
  • Use sunsetr preset default to return to your main configuration
  • Or call same preset twice to return to default as well
  • Resolves issue #16 by enabling easy toggling of static temperature/gamma values

Usage:

# Switch to a specific preset
sunsetr preset day # sets static day temp/gamma

# Return to default configuration
sunsetr preset day

You can also set a keybind for toggling:

# Hyprland hyprland.conf
bind = $mod, W, exec, sunsetr p day
// Niri config.kdl
Mod+W hotkey-overlay-title="sunsetr gaming toggle" { spawn "sh" "-c" "sunsetr p gaming"; }

Configuration: Create preset files in ~/.config/sunsetr/presets/ (or with a custom base config directory using --config):

~/.config/sunsetr/
├── .active_preset       # Stores active preset
├── geo.toml             # default geo.toml
├── presets
│   ├── day
│   │   └── sunsetr.toml # static day values
│   ├── gaming
│   │   └── sunsetr.toml # custom static gamma
│   ├── hong_kong
│   │   └── sunsetr.toml # custom geo mode
│   ├── london
│   │   ├── geo.toml     # preset's geo.toml
│   │   └── sunsetr.toml # custom geo mode
│   ├── summer
│   │   ├── geo.toml     # preset's geo.toml
│   │   └── sunsetr.toml # custom geo for summer time
│   └── weekend
│       └── sunsetr.toml # custom manual sunset/sunrise
└── sunsetr.toml         # default config
  • Each preset has the option to use its own geo.toml for private coordinates (using .gitignore) when using geo transition_mode.
  • The active preset is stored in .active_preset. You can manually edit this, but I suggest letting sunsetr handle it to avoid confusion.
  • Running the geo command gives you the option to change the active preset's coordinates (which also respects the preset's geo.toml)
  • Running with --simulate allows you to simulate that preset's runtime during an arbitrary time window (must be active preset)

Note: v0.10.0 will release a config builder that allows you to quickly build new presets automatically. This should simplify making a valid config significantly.

Custom Configuration Directories

  • New --config flag to specify custom configuration directories (#22)
  • Allows for portable configurations and easier testing
  • Full integration with preset system and hot reloading

Usage:

# Use a custom config directory
sunsetr --config ~/dotfiles/sunsetr/

# Commands work with custom directories
sunsetr --config ~/my-configs/sunsetr/ preset weekend
sunsetr --config ~/my-configs/sunsetr/ geo

# Directory structure remains the same
~/my-configs/sunsetr
├── geo.toml
├── presets
│   ├── weekend
│   │   └── sunsetr.toml
│   └── tokyo
│       └── sunsetr.toml
└── sunsetr.toml

Note: If you use a custom base directory, you do not need to keep using the --config flag. Just running it once allows you to use all of the commands (including the new preset command) and they will respect the new base config directory for the life of that process. To switch the base config directory, you will need to stop sunsetr and restart using the new directory. This allows all of the commands to respect the base config directory for the life of the process.

Hot Reloading

  • Live configuration updates without restarting sunsetr (#22)
  • Intelligent file watching that detects changes to your active config files
  • Automatic reload when configuration files are modified
  • Works seamlessly with the new --config flag for custom directories

Usage:

# Start sunsetr - it will auto-reload on config changes
sunsetr

# Or start in background with the reload command
sunsetr reload

# Then:

# Edit your active config - changes apply automatically
vim ~/.config/sunsetr/sunsetr.toml

Note: Hot reloading applies only to the active default config (or active presets) in the active base config directory. For instance, if you run sunsetr --config ~/.custom/sunsetr preset day, then change the values for this config's static_gamma and save, it'll automatically reload the gamma percentage. You would edit this preset in ~/.custom/sunsetr/preset/day/sunsetr.toml

# ~/.custom/sunsetr/preset/day/sunsetr.toml
├── geo.toml
├── presets
│   ├── day
│   │   └── sunsetr.toml # <-- Edit here
│   └── overseas
│       ├── geo.toml
│       └── sunsetr.toml
└── sunsetr.toml

Enhanced Smooth Transitions

  • Comprehensive smooth transitions for both startup and shutdown
  • Configurable startup transition timing with adaptive interval algorithm (An effort to reduce lag for #21)
  • Eliminates jarring gamma changes when starting or stopping
  • Intelligent transition detection prevents redundant gamma resets

Configuration:

#[Smoothing]
smoothing = true         # Enable/disable smooth transitions
startup_duration = 0.5   # Seconds for startup transition (0.1-60, 0=instant)
shutdown_duration = 0.5  # Seconds for shutdown transition (0.1-60, 0=instant)
adaptive_interval = 1    # Base interval for adaptive algorithm (1-1000ms)
  1. startup_transition is now smoothing
  2. startup_transition_duration is now startup_duration
  3. New configurable shutdown_duration for smooth transitions during exit
  4. New adaptive_interval allows user to configure the base interval (floor) from which the adaptive update interval begins scaling. This automatically adjusts to your system's capabilities. Leave at 1ms for the best results and highest granularity.

Note: Changing the adaptive_interval allows you to control the floor the smooth transition intelligently scales up from but will never go lower than. Setting this to higher values like 150(ms) will negate the algorithm's ability to automatically create the smoothest transition, but will allow you to reduce the number of updates for use with longer startup_duration and shutdown_duration values. You may be able to find a sweet spot between compositor rendering lag (affects mouse and other rendering updates) and smoothness of the temp/gamma transition. For longer transitions, you can use something like this:

#[Smoothing]
smoothing = true         # Enable/disable smooth transitions
startup_duration = 5     # Seconds for startup transition (0.1-60, 0=instant)
shutdown_duration = 5    # Seconds for shutdown transition (0.1-60, 0=instant)
adaptive_interval = 150  # Base interval for adaptive algorithm (1-1000ms)

CLI Architecture Improvements

  • Subcommand-based CLI with full backward compatibility
  • Cleaner command organization and better help documentation
  • More intuitive command structure while preserving existing workflows

Technical Improvements

System Monitoring

  • Improved D-Bus signal handling with automatic thread restart on failure
  • Better recovery from system sleep/resume cycles
  • Replaced time anomaly detection with event-driven system monitoring
  • More efficient and reliable detection of system state changes
  • Better handling of sleep/resume events with privacy-focused debug logging

Code Organization

  • Refactored config.rs into a modular structure with separate files for:
    • Configuration building
    • Loading and file operations
    • Validation logic
    • File watching
  • Renamed internal components for clarity (e.g., AdaptiveInterval → AdaptiveThrottle)
  • Simplified constants and removed obsolete code

💛 Acknowledgments

Thanks to all contributors and users who provided feedback and testing for this release. Special thanks for the feature requests and bug reports that shaped these improvements @ItsLemmy and @The-Lost-Light.

Don't miss a new sunsetr release

NewReleases is sending notifications on new releases.