Jump to content

Redshift: Difference between revisions

From Official NixOS Wiki
Phobos (talk | contribs)
mNo edit summary
Phobos (talk | contribs)
mNo edit summary
Line 10: Line 10:


== Installation ==
== Installation ==
==== Using nix-shell ====
<syntaxhighlight lang="console">
$ nix-shell -p redshift
</syntaxhighlight>
==== Using Global Configuration ====
==== Using Global Configuration ====
{{File|3=environment.systemPackages = [
{{File|3=environment.systemPackages = [
  pkgs.redshift
  pkgs.redshift
];|name=/etc/nixos/configuration.nix|lang=nix}}
];|name=/etc/nixos/configuration.nix|lang=nix}}
After modifying your configuration, apply the changes by running:<syntaxhighlight lang="console">
$ sudo nixos-rebuild switch
</syntaxhighlight>
==== Using Home Configuration ====
==== Using Home Configuration ====
{{File|3=home.packages = [  
{{File|3=home.packages = [  
   pkgs.redshift  
   pkgs.redshift  
];|name=/etc/nixos/home.nix|lang=nix}}
];|name=/etc/nixos/home.nix|lang=nix}}
After updating your configuration, apply the changes by running:<syntaxhighlight lang="console">
$ home-manager switch
</syntaxhighlight>
== Configuration ==
== Configuration ==
==== Using Global Configuration: ====
==== Using Global Configuration: ====
Options may be found under [https://search.nixos.org/options?query=services.redshift services.redshift].{{File|3=services.redshift = {
Options may be found under [https://search.nixos.org/options?query=services.redshift services.redshift]. For more options for configuring Geoclue, check the [[Geoclue|Geoclue page]].{{File|3=services.redshift = {
   enable = true;
   enable = true;
   temperature = {
   temperature = {

Revision as of 18:46, 30 November 2025

Redshift is an open-source software application designed to adjust color temperature of screens based on the time of day.

It does this by gradually shifting the color temperature of the display to reduce the amount of blue light towards the night, and increasing the amount of blue light in the morning.

Users may choose to have screen temperature automatically match their lighting based my geographic location, or based on manually set time-frames. Users may also customize day and night color temperatures, adjust the speed of transitions, and more.

Redshift is unmaintained and does not support Wayland. It is best used on X11 systems.

For Wayland support you may consider Gammastep, a modern fork of Redshift. Alternatively there is also wlsunset, which is a lightweight modern alternative.

Installation

Using Global Configuration

❄︎ /etc/nixos/configuration.nix
environment.systemPackages = [
  pkgs.redshift
];

Using Home Configuration

❄︎ /etc/nixos/home.nix
home.packages = [ 
  pkgs.redshift 
];

Configuration

Using Global Configuration:

Options may be found under services.redshift. For more options for configuring Geoclue, check the Geoclue page.

❄︎ /etc/nixos/configuration.nix
services.redshift = {
  enable = true;
  temperature = {
    day = 5500;
    night = 3700;
  };
};

services.geoclue2.enable = true;
location.provider = "geoclue2";

Advanced (Home Manager)

❄︎ /etc/nixos/home.nix
services.redshift = {
  enable = true;
  
  # Display temperature settings
  temperature = {
    day = 5700;
    night = 3500;
  };
  
  # Location settings (replace with your coordinates)
  latitude = "27.9880614";
  longitude = "86.92521";
  
  # Schedule settings
  dawnTime = "6:00-7:45";
  duskTime = "18:35-20:15";
  
  # General settings
  brightness = {
    day = "1";
    night = "0.8";
  };
  
  extraOptions = [
    "-v"
    "-m randr"
  ];

  tray = false;

};

# Setting the location works either by using a provider
services.geoclue2.enable = true;
location.provider = "geoclue2";

# Or like this, which can also be set in services.redshift
location.latitude = "27.9880614";
location.longitude = "86.92521";

Tips and Tricks

Location of Options

The Home Manager options are defined in the Home Manager Options Manual.

The global options can be found under services.redshift.

Usage

# If services.redshift.enable is true, the systemd unit redshift.service is provided. 
# It can either be started by the user level service manager like this:
systemctl --user start redshift

# Or permanantly enabled by creating the empty file
~/.config/systemd/user/default.target.wants/redshift.service

# After starting the service, make sure to check its status in the service manager:
systemctl --user status redshift

Troubleshooting

Provider is unable to determine location

It may happen that Redshift gets stuck at "Waiting for initial location to become available..." when using the geoclue2 location provider. This may happen when Geoclue is unable to determine your location due to missing information. In that case, you may resort to setting the location manually or using an alternate location service such as beaconDB, which can take advantage of WiFi scanning.

An example of using beaconDB as an alternative:

❄︎ /etc/nixos/configuration.nix
location.provider = "geoclue2";
services.geoclue2 = {
    enable = true;
    geoProviderUrl = "https://api.beacondb.net/v1/geolocate";
  };

References