Jump to content

Redshift: Difference between revisions

From Official NixOS Wiki
Layer-09 (talk | contribs)
Changed the layout, added more information
Phobos (talk | contribs)
mNo edit summary
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[http://jonls.dk/redshift/ Redshift] is an open-source software application designed to adjust the color temperature of computer displays based on the time of day. Created by Jon Lund Steffensen, Redshift modifies the color temperature to reduce eye strain and improve sleep patterns. This application aims to provide a more comfortable viewing experience by dynamically changing the display's color temperature to match the user's surrounding light conditions.
[https://github.com/jonls/redshift 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 from cooler (bluer) tones during the day to warmer (redder) tones at night.
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 have the flexibility to customize various settings in Redshift. They can specify custom values for day and night color temperatures, adjust the speed of color transitions, and temporarily disable or manually adjust the color temperature.
Users may choose to have screen temperature automatically match their lighting based on 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 best used on X11 systems as it is unmaintained and does not support Wayland.
 
For Wayland support you may consider [[Gammastep]], a modern fork of Redshift. Alternatively there is also [[wlsunset]], which is a lightweight modern alternative.


== Installation ==
== Installation ==
 
==== Using Global Configuration ====
==== Basic ====
{{File|3=environment.systemPackages = [
<syntaxHighlight lang=nix>
  pkgs.redshift
# location.provider = "geoclue2"
];|name=/etc/nixos/configuration.nix|lang=nix}}
# All values except 'enable' are optional.
==== Using Home Configuration ====
services.redshift = {
{{File|3=home.packages = [
  pkgs.redshift
];|name=/etc/nixos/home.nix|lang=nix}}
== Configuration ==
==== Global Configuration: ====
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 = {
Line 18: Line 27:
   };
   };
};
};
</syntaxHighlight>


==== Advanced ====
services.geoclue2.enable = true;
<syntaxHighlight lang=nix>
location.provider = "geoclue2";|name=/etc/nixos/configuration.nix|lang=nix}}
services.redshift = {
 
==== Home Manager ====
 
===== Example Usage =====
You can find more options in [https://nix-community.github.io/home-manager/options.xhtml#opt-services.redshift.enable Home Manager: services.redshift]. This configuration defines the temperature the display will use at night and day, the schedule and length of the transition, brightness for the display to use, and whether it will use a tray icon. <code>extraOptions</code> defines additional command-line arguments to pass to <code>redshift</code>.
{{File|3=services.redshift = {
   enable = true;
   enable = true;
    
    
   # Display temperature settings
   # Display temperature settings (in Kelvin)
   temperature = {
   temperature = {
     day = 5700;
     day = 5500;
     night = 3500;
     night = 3500;
   };
   };
 
  # Location settings (replace with your coordinates)
  latitude = "27.9880614";
  longitude = "86.92521";
    
    
   # Schedule settings
   # Schedule settings
   settings = {
   dawnTime = "6:00-7:45";
    dawn-time = "6:00-7:45";
  duskTime = "18:35-20:15";
    dusk-time = "18:35-20:15";
  };
    
    
   # General settings
   # Brightness
   brightness = {
   brightness = {
     day = "1";
     day = "1";
Line 51: Line 58:
     "-m randr"
     "-m randr"
   ];
   ];
};
 
  # Tray Icon
  tray = false;


# Setting the location works either by using a provider
};|name=/etc/nixos/home.nix|lang=nix}}
services.geoclue2.enable = true;
location.provider = "geoclue2";


# Or like this, which can also be set in services.redshift
===== Location Based Transitions =====
location.latitude = "27.9880614";
You can choose to use Redshift with location based screen temperature to match when the sun actually sets and rises in your area. Below are examples of those options using [https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home Geoclue] and manually set coordinates.
location.longitude = "86.92521";
</syntaxHighlight>


== Tips and Tricks ==
====== Geoclue ======
==== Location of Options ====
Geoclue provides location using GPS, 3G modems, GeoIP, and WiFi Geolocation. Some integrations may require additional setup.{{File|3=services.redshift = {
The home manager options are defined in the following [https://nix-community.github.io/home-manager/options.xhtml#opt-services.gammastep.enable Home Manager Options Manual].
  enable = true;
  provider = "geoclue2";
};|name=/etc/nixos/home.nix|lang=nix}}You will also need to enable Geoclue in your global configuration [[Geoclue|(See options on the Geoclue page)]].
{{File|3=services.geoclue2.enable = true;
location.provider = "geoclue2";|name=/etc/nixos/configuration.nix|lang=nix}}


The global options are listed on [https://mynixos.com/search?q=redshift MyNixOS].
====== Coordinates ======
{{File|3=services.redshift = {
  enable = true;


==== Usage ====
  # Coordinates based location
<syntaxHighlight lang="shell">
  provider = "manual";
# 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
  latitude = "27.9880614";
~/.config/systemd/user/default.target.wants/redshift.service
  longitude = "86.92521";


# After starting the service, make sure to check its status in the service manager:
};|name=/etc/nixos/home.nix|lang=nix}}
systemctl --user status redshift
Instead of declaring your coordinates in Redshift, you can also declare them globally for your device in your global configuration:
</syntaxHighlight>
{{File|3=location = {
  provider = "manual";
  latitude = "27.9880614";
  longitude = "86.92521";
};|name=/etc/nixos/configuration.nix|lang=nix}}


== Troubleshooting ==
== Troubleshooting ==
==== Provider is unable to determine location ====
==== Provider is unable to determine location ====
It may happen that redshift gets stuck at ''"Waiting for initial location to become available..."'' when using the {{Ic|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.
It may happen that Redshift gets stuck at ''"Waiting for initial location to become available..."'' when using the {{Ic|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 [https://beacondb.net/ beaconDB], which can take advantage of WiFi scanning.
 
An example of using beaconDB as an alternative:
 
{{File|3=location.provider = "geoclue2";
services.geoclue2 = {
    enable = true;
    geoProviderUrl = "https://api.beacondb.net/v1/geolocate";
  };|name=/etc/nixos/configuration.nix|lang=nix}}


== References ==
== References ==
* https://github.com/jonls/redshift
* https://github.com/jonls/redshift
* https://nix-community.github.io/home-manager/options.xhtml#opt-services.gammastep.enable
* https://nix-community.github.io/home-manager/options.xhtml#opt-services.gammastep.enable
* https://mynixos.com/search?q=redshift
* https://search.nixos.org/options?query=redshift


[[Category:Applications]]
[[Category:Applications]]

Latest revision as of 20:18, 3 December 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 on 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 best used on X11 systems as it is unmaintained and does not support Wayland.

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

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";

Home Manager

Example Usage

You can find more options in Home Manager: services.redshift. This configuration defines the temperature the display will use at night and day, the schedule and length of the transition, brightness for the display to use, and whether it will use a tray icon. extraOptions defines additional command-line arguments to pass to redshift.

❄︎ /etc/nixos/home.nix
services.redshift = {
  enable = true;
  
  # Display temperature settings (in Kelvin)
  temperature = {
    day = 5500;
    night = 3500;
  };
  
  # Schedule settings
  dawnTime = "6:00-7:45";
  duskTime = "18:35-20:15";
  
  # Brightness
  brightness = {
    day = "1";
    night = "0.8";
  };
  
  extraOptions = [
    "-v"
    "-m randr"
  ];
  
  # Tray Icon
  tray = false;

};
Location Based Transitions

You can choose to use Redshift with location based screen temperature to match when the sun actually sets and rises in your area. Below are examples of those options using Geoclue and manually set coordinates.

Geoclue

Geoclue provides location using GPS, 3G modems, GeoIP, and WiFi Geolocation. Some integrations may require additional setup.

❄︎ /etc/nixos/home.nix
services.redshift = {
  enable = true;
  provider = "geoclue2";
};

You will also need to enable Geoclue in your global configuration (See options on the Geoclue page).

❄︎ /etc/nixos/configuration.nix
services.geoclue2.enable = true;
location.provider = "geoclue2";
Coordinates
❄︎ /etc/nixos/home.nix
services.redshift = {
  enable = true;

  # Coordinates based location
  provider = "manual";

  latitude = "27.9880614";
  longitude = "86.92521";

};

Instead of declaring your coordinates in Redshift, you can also declare them globally for your device in your global configuration:

❄︎ /etc/nixos/configuration.nix
location = {
  provider = "manual";
  latitude = "27.9880614";
  longitude = "86.92521";
};

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