{pkgs, ...}: {
  # Expose CLI tool
  home.packages = [pkgs.sunsetr];

  systemd.user.services.sunsetr = {
    Unit = {
      Description = "Sunsetr blue-light filtering";
      PartOf = ["waylandwm-session.target"];
      After = ["graphical-session.target"];
    };

    Service = {
      Type = "simple";
      ExecStart = "${pkgs.sunsetr}/bin/sunsetr -b";
      Restart = "on-failure";
      RestartSec = 1;
      TimeoutStopSec = 10;
    };

    Install = {
      WantedBy = ["niri.service"];
    };
  };

  xdg.configFile."sunsetr/sunsetr.toml".text = ''
    #[Backend]
    backend = "auto"         # Backend to use: "auto", "hyprland", "hyprsunset" or "wayland"
    transition_mode = "geo"  # Select: "geo", "finish_by", "start_at", "center", "static"

    #[Smoothing]
    smoothing = true         # Enable smooth transitions during startup and exit
    startup_duration = 0.5   # Duration of smooth startup in seconds (0.1-60 | 0 = instant)
    shutdown_duration = 0.5  # Duration of smooth shutdown in seconds (0.1-60 | 0 = instant)
    adaptive_interval = 1    # Adaptive interval base for smooth transitions (1-1000)ms

    #[Time-based config]
    night_temp = 3300        # Color temperature during night (1000-20000) Kelvin
    day_temp = 6500          # Color temperature during day (1000-20000) Kelvin
    night_gamma = 90         # Gamma percentage for night (10-200%)
    day_gamma = 100          # Gamma percentage for day (10-200%)
    update_interval = 60     # Update frequency during transitions in seconds (10-300)

    #[Static config]
    static_temp = 6500       # Color temperature for static mode (1000-20000) Kelvin
    static_gamma = 100       # Gamma percentage for static mode (10-200%)

    #[Manual transitions]
    sunset = "19:00:00"      # Time for manual sunset calculations (HH:MM:SS)
    sunrise = "06:00:00"     # Time for manual sunrise calculations (HH:MM:SS)
    transition_duration = 45 # Transition duration in minutes (5-120)

    #[Geolocation]
    latitude = 55.950000     # Geographic latitude (auto-detected on first run)
    longitude = -3.200000    # Geographic longitude (use 'sunsetr geo' to change)
  '';
}
