Redshift: Difference between revisions

imported>Onny
mNo edit summary
Phobos (talk | contribs)
mNo edit summary
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[http://jonls.dk/redshift/ Redshift] is a program that adjusts the color temperature of your screen according to your surroundings. By reducing the amount of blue light emitted it may help to reduce strain on the eyes if working in front of the screen at night. It's functionality is similar to f.lux.
[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.  


== Prerequisites ==
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.


To properly work, Redshift needs your location to know when the sun will be setting and it gets dark outside, so that it can automatically adjust your screen temperature accordingly.
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.
You can either manually configure a location or specify a location provider such as geoclue2 with the following options:


* [https://search.nixos.org/options/?query=location.provider {{ic|location.provider}}]
Redshift is best used on X11 systems as it is unmaintained and does not support Wayland.  
* [https://search.nixos.org/options/?query=location.latitude {{ic|location.latitude}}] (Used by the {{ic|manual}} provider.)
 
* [https://search.nixos.org/options/?query=location.longitude {{ic|location.longitude}}] (Used by the {{ic|manual}} provider.)
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 ====
{{File|3=environment.systemPackages = [
  pkgs.redshift
];|name=/etc/nixos/configuration.nix|lang=nix}}
==== Using Home Configuration ====
{{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;
  temperature = {
    day = 5500;
    night = 3700;
  };
};


Enable <syntaxhighlight lang="nix" inline>services.redshift</syntaxhighlight>.
services.geoclue2.enable = true;
Example snippet of <code>configuration.nix</code>:
location.provider = "geoclue2";|name=/etc/nixos/configuration.nix|lang=nix}}
<syntaxHighlight lang=nix> ...
 
{ config, pkgs, callPackage, ... }: {
==== Home Manager ====
   ...
 
   # location.provider = "geoclue2"
===== Example Usage =====
   # All values except 'enable' are optional.
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>.
   services.redshift = {
{{File|3=services.redshift = {
     enable = true;
   enable = true;
     brightness = {
    
      # Note the string values below.
   # Display temperature settings (in Kelvin)
      day = "1";
   temperature = {
      night = "1";
     day = 5500;
    };
     night = 3500;
    temperature = {
  };
      day = 5500;
 
      night = 3700;
  # Schedule settings
    };
  dawnTime = "6:00-7:45";
  duskTime = "18:35-20:15";
 
  # Brightness
  brightness = {
    day = "1";
    night = "0.8";
   };
   };
};
 
</syntaxHighlight>
  extraOptions = [
    "-v"
    "-m randr"
  ];
 
  # Tray Icon
  tray = false;
 
};|name=/etc/nixos/home.nix|lang=nix}}
 
===== 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 [https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home Geoclue] and manually set coordinates.
 
====== Geoclue ======
Geoclue provides location using GPS, 3G modems, GeoIP, and WiFi Geolocation. Some integrations may require additional setup.{{File|3=services.redshift = {
  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}}
 
====== Coordinates ======
{{File|3=services.redshift = {
  enable = true;
 
  # Coordinates based location
  provider = "manual";
 
  latitude = "27.9880614";
  longitude = "86.92521";
 
};|name=/etc/nixos/home.nix|lang=nix}}
Instead of declaring your coordinates in Redshift, you can also declare them globally for your device in your global configuration:
{{File|3=location = {
  provider = "manual";
  latitude = "27.9880614";
  longitude = "86.92521";
};|name=/etc/nixos/configuration.nix|lang=nix}}
 
== 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 {{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.


== Usage ==
An example of using beaconDB as an alternative:
If <syntaxhighlight lang="nix" inline>services.redshift.enable</syntaxhighlight> is true, the systemd unit <syntaxhighlight inline>redshift.service</syntaxhighlight> is provided. It can either be started by the user level service manager like this:
<syntaxHighlight lang="shell">
systemctl --user start redshift
</syntaxHighlight>
Or permanantly enabled by creating the empty file
<syntaxHighlight lang="shell">
~/.config/systemd/user/default.target.wants/redshift.service
</syntaxHighlight>


After starting the service, make sure to check its status in the service manager:
{{File|3=location.provider = "geoclue2";
<syntaxHighlight lang="shell">
services.geoclue2 = {
systemctl --user status redshift
    enable = true;
</syntaxHighlight>
    geoProviderUrl = "https://api.beacondb.net/v1/geolocate";
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.
  };|name=/etc/nixos/configuration.nix|lang=nix}}


== See also ==
== References ==
* [[Gammastep]], alternative implementation supporting Wayland compositors
* https://github.com/jonls/redshift
* https://nix-community.github.io/home-manager/options.xhtml#opt-services.gammastep.enable
* https://search.nixos.org/options?query=redshift


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