Redshift: Difference between revisions

From ArchWiki
m (Add simple chinese page link)
(Clarify how the GeoClue agent is autostarted.)
 
(74 intermediate revisions by 33 users not shown)
Line 2: Line 2:
[[Category:Eye candy]]
[[Category:Eye candy]]
[[ja:Redshift]]
[[ja:Redshift]]
[[ru:Redshift]]
[[zh-hans:Redshift]]
[[zh-hans:Redshift]]
From the [http://jonls.dk/redshift/ Redshift project web page]:
From the [http://jonls.dk/redshift/ Redshift project web page]:


:[[Wikipedia:Redshift (software)|Redshift]] adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night. This program is inspired by [http://justgetflux.com f.lux].
:[[Wikipedia:Redshift (software)|Redshift]] adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night. This program is inspired by the closed-source application [https://justgetflux.com f.lux].


{{Note|Redshift does not support [[Wayland]] since it offers no way to adjust the color temperature [https://github.com/jonls/redshift/issues/55]. See [[Wayland#Gamma]] for more.}}
{{Note|Redshift does not support [[Wayland]] [https://github.com/jonls/redshift/issues/55]. See [[Backlight#Wayland]] for alternatives.}}


== Installation ==
== Installation ==
Line 18: Line 17:
The ''redshift-gtk'' command comes with the {{Pkg|redshift}} package and provides a system tray icon for controlling Redshift. See optional dependencies.
The ''redshift-gtk'' command comes with the {{Pkg|redshift}} package and provides a system tray icon for controlling Redshift. See optional dependencies.


Alternatives are {{AUR|redshiftgui-bin}} (GTK) and {{AUR|redshift-qt}}, {{AUR|redshiftconf}} or {{Pkg|plasma5-applets-redshift-control}} and {{AUR|plasma5-applets-redshift-control-git}} (Qt).
Alternatives are {{AUR|redshift-qt}}, {{AUR|redshiftconf}} or {{AUR|plasma5-applets-redshift-control-git}}.


== Usage ==
== Usage ==
Line 30: Line 29:
  $ redshift -l ''LATITUDE'':''LONGITUDE''
  $ redshift -l ''LATITUDE'':''LONGITUDE''


where ''LATITUDE'' is the latitude and ''LONGITUDE'' is the longitude of your location.
where {{ic|''LATITUDE''}} is the latitude and {{ic|''LONGITUDE''}} is the longitude of your location.


{{Tip|You can get the coordinates of a place with [http://www.geonames.org/ GeoNames.org].}}
{{Tip|You can get the coordinates of a place with [https://www.geonames.org/ GeoNames.org].}}


To instantly adjusts the color temperature of your screen use:
To instantly adjust the color temperature of your screen use:


  $ redshift -P -O ''TEMPERATURE''
  $ redshift -P -O ''TEMPERATURE''


where ''TEMPERATURE'' is the desired color temperature (between {{ic|1000}} and {{ic|25000}}).
where {{ic|''TEMPERATURE''}} is the desired [[Wikipedia:Color temperature|color temperature]] (between {{ic|1000}} and {{ic|25000}}).


=== Autostart ===
=== Autostart ===


There are several options to have redshift automatically started:
There are several options to have Redshift automatically started:


* By right-clicking the system tray icon and selecting ''Autostart'' when ''redshift-gtk'' or ''plasma5-applets-redshift-control'' is already launched.
* By right-clicking the system tray icon and selecting ''Autostart'' when ''redshift-gtk'' or ''plasma5-applets-redshift-control'' is already launched.
* By placing a Redshift [[Desktop entry]] in {{Ic|~/.config/autostart/}} or by adding {{ic|redshift}} to your window manager or desktop environment's [[Autostarting]] method.  
* By placing a Redshift [[desktop entry]] in {{ic|~/.config/autostart/}} or by adding {{ic|redshift}} to your window manager or desktop environment's [[autostarting]] method.  
* By using [[Systemd/User]]. Two services are provided: {{ic|redshift.service}} and {{ic|redshift-gtk.service}}. Activate only one of them depending on whether or not you want the system tray icon.
* By using the [[user unit]]s provided: {{ic|redshift.service}} and {{ic|redshift-gtk.service}}. Activate only one of them depending on whether or not you want the system tray icon.


{{Note|
{{Note|
* The Redshift service files contain {{ic|1=Restart=always}} so they will restart infinitely. See {{man|5|systemd.service}}.
* The Redshift service files contain {{ic|1=Restart=always}} so they will restart infinitely. See {{man|5|systemd.service}}.
* When using a systemd user service, [[Xorg]] must be started before execution of the service, which is not the case without a [[Display Manager]]. Otherwise you will get {{ic|RANDR Query Version' returned error -1}} and {{ic|Initialization of randr failed}}.}}
* When using a systemd user service, [[Xorg]] must be started before execution of the service, which is not the case without a [[display manager]]. Otherwise you will get {{ic|RANDR Query Version' returned error -1}} and {{ic|Initialization of randr failed}}. This is already accounted for in the [[systemd/User]] method above, which contains {{ic|1=After=display-manager.service}}.}}


== Configuration ==
=== Toggle ===


Redshift reads the configuration file {{ic|~/.config/redshift/redshift.conf}} [https://github.com/jonls/redshift/releases/tag/v1.12] if it exists. However, Redshift does not create that configuration file, so you may want to create it manually. See [https://raw.githubusercontent.com/jonls/redshift/master/redshift.conf.sample redshift.conf.sample].
Redshift will continously update the color temperature at regular intervals. One shot mode can be selected if you only want to do one adjustment. The color adjustments done by Redshift can be temporarily toggled on and off by sending it the USR1 signal:


=== Automatic location based on GeoClue2 ===
$ pkill -USR1 redshift


In order to allow access Redshift to use GeoClue2, add the following lines to {{ic|/etc/geoclue/geoclue.conf}}:
== Configuration ==


{{hc|/etc/geoclue/geoclue.conf|2=
Redshift reads the configuration file {{ic|~/.config/redshift/redshift.conf}} [https://github.com/jonls/redshift/releases/tag/v1.12] if it exists. However, Redshift does not create that configuration file, so you may want to create it manually. See [https://raw.githubusercontent.com/jonls/redshift/master/redshift.conf.sample redshift.conf.sample].
[redshift]
allowed=true
system=false
users=
}}


[[Restart]] {{ic|redshift.service}} and/or any other Redshift instance to apply the changes.
=== Specify location manually ===


{{Note|
Redshift calculates the sunrise and sunset times based on geographic coordinates. It can be specified manually by using the {{ic|manual}} location-provider, e.g. for Paris:
* This workaround is not needed with Geoclue2 version 2.5.0 and above.
* If using [[GNOME]], also toggle Location Services to "On" in ''Settings > Privacy''.
* Due possible bugs with geoclue2 and Redshift [https://github.com/jonls/redshift/issues/318], it may be required to use the {{ic|manual}} location-provider instead, e.g. for Paris:


{{hc|~/.config/redshift/redshift.conf|2=
{{hc|~/.config/redshift/redshift.conf|2=
[redshift]
[redshift]
...
...
; Set the location-provider: 'geoclue2', 'manual'
; type 'redshift -l list' to see possible values.
; The location provider settings are in a different section.
location-provider=manual
location-provider=manual
...
...
; Keep in mind that longitudes west of Greenwich (e.g. the Americas)
; are negative numbers.
[manual]
[manual]
lat=48.853
lat=48.864716
lon=2.349
lon=2.349014
}}
}}


* If using [[i3wm]] or similar, you will also need to enable the geoclue agent on startup. As well as {{ic|systemctl --user enable redshift-gtk}} or {{ic|redshift}} user service.
=== Automatic location based on GeoClue ===
 
Redshift uses the {{ic|geoclue2}} location-provider by default. It needs a GeoClue agent running in the background. It is supposed to work without further configuration, but if you experience problems, see [[#Unable to connect to GeoClue]].
 
=== Automatic location based on Mozilla Location Service ===
 
You can use [[cURL]] to get the location data and parse it into the format required by Redshift. For example, Mozilla provides json location data that can be parsed with {{Pkg|jq}} as follows:
 
redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | jq -r '"\(.location.lat):\(.location.lng)"')
 
or with awk if jq is not on the system:
 
redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | awk 'OFS=":" {print $3,$5}' | tr -d ',}')
 
or with sed:


{{hc|~/.i3/config|2=
redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | sed 's/.*"lat": \(-\?[0-9.]*\).*"lng": \(-\?[0-9.]*\).*/\1:\2/')
...
exec --no-startup-id /usr/lib/geoclue-2.0/demos/agent
...}}
}}


=== Automatic location based on GPS ===
=== Automatic location based on GPSD ===


You can also use {{Pkg|gpsd}} to automatically determine your [[GPS]] location and use it as an input for Redshift. Create the following script and pass {{ic|$lat}} and {{ic|$lon}} to {{ic|redshift -l $lat;$lon}}:
You can also use {{Pkg|gpsd}} to automatically determine your [[GPS]] location and use it as an input for Redshift. Create the following script and pass {{ic|$lat}} and {{ic|$lon}} to {{ic|redshift -l $lat;$lon}}:
Line 120: Line 114:
Redshift has a brightness adjustment setting, but it does not work the way most people might expect. In fact it is a fake brightness adjustment obtained by manipulating the gamma ramps, which means that it does not reduce the backlight of the screen. [http://jonls.dk/redshift/#known-bugs-and-limitations]
Redshift has a brightness adjustment setting, but it does not work the way most people might expect. In fact it is a fake brightness adjustment obtained by manipulating the gamma ramps, which means that it does not reduce the backlight of the screen. [http://jonls.dk/redshift/#known-bugs-and-limitations]


Changing screen backlight is possible with redshift hooks and {{pkg|xorg-xrandr}} and {{pkg|xorg-xbacklight}} but, please see [[Backlight#xbacklight]] as there are some limitations and you may have to find another method of controlling the backlight depending on your hardware.
Changing screen backlight is possible with redshift hooks and {{pkg|acpilight}}, but please see [[Backlight#xbacklight]] as there are some limitations and you may have to find another method of controlling the backlight depending on your hardware.


You need to create a file in {{ic|~/.config/redshift/hooks}} and make it executable. You can use and edit the following example:
You need to create a file in {{ic|~/.config/redshift/hooks}} and make it executable. You can use and edit the following example:
$ mkdir -p ~/.config/redshift/hooks
Create and adjust the following script:


{{hc|~/.config/redshift/hooks/brightness.sh|output=
{{hc|~/.config/redshift/hooks/brightness.sh|output=
#!/bin/sh
#!/bin/sh
# Set brightness via xbrightness when redshift status changes
# Set brightness via xbrightness when redshift status changes


# Set brightness values for each status.
# Set brightness values for each status.
# Range from 1 to 100 is valid
# Range from 1 to 100 is valid
brightness_day=100
brightness_day=85
brightness_transition=50
brightness_transition=50
brightness_night=10
brightness_night=30
# Set fade time for changes to one minute
# Set fps for smoooooth transition
fade_time=60000
fps=1000
# Adjust this grep to filter only the backlights you want to adjust
backlights=($(xbacklight -list {{!}} grep ddcci*))
 
set_brightness() {
for backlight in "${backlights[@]}"
do
xbacklight -set $1 -fps $fps -ctrl $backlight &
done
}


if [ "$1" = period-changed ]; then
if [ "$1" = period-changed ]; then
case $3 in
case $3 in
night)
night)
xbacklight -set $brightness_night -time $fade_time
set_brightness $brightness_night  
;;
;;
transition)
transition)
xbacklight -set $brightness_transition -time $fade_time
set_brightness $brightness_transition
;;
;;
daytime)
daytime)
xbacklight -set $brightness_day -time $fade_time
set_brightness $brightness_day
;;
;;
esac
esac
Line 156: Line 154:
}}
}}


Make it [[executable]]:
Make it [[executable]] and [[restart]] the {{ic|redshift.service}} to apply changes.
 
$ chmod +x ~/.config/redshift/hooks/brightness.sh
 
[[Restart]] the {{ic|redshift.service}} to apply changes.


Check the service status as it should '''not''' contain the following message:
Check the service status as it should '''not''' contain the following message:
Line 167: Line 161:


== Troubleshooting ==
== Troubleshooting ==
=== Unable to connect to GeoClue ===
If running {{ic|$ redshift}} and you are getting:
Unable to obtain GeoClue client path: Timeout was reached.
Then make sure that a GeoClue agent is running. GNOME Shell [https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/status/location.js provides an agent itself]. For other desktop environments, a demo agent ({{ic|/usr/lib/geoclue-2.0/demos/agent}}) is [https://gitlab.freedesktop.org/geoclue/geoclue/-/blob/master/demo/geoclue-demo-agent.desktop.in.in autostarted]. You can check if GeoClue works properly by checking the output of the {{ic|/usr/lib/geoclue-2.0/demos/where-am-i}} command.
If you are using a desktop environment that does not support [[XDG Autostart]], then you have to start the demo agent manually, or you can create a [[systemd]] unit file with the following config:
{{hc|~/.config/systemd/user/geoclue-agent.service|2=
[Unit]
Description=redshift needs to get a (geo)clue
[Service]
ExecStart=/usr/lib/geoclue-2.0/demos/agent
[Install]
WantedBy=default.target
}}
Then [[start/enable]] the {{ic|geoclue-agent.service}} [[user unit]].


=== Screen 1 could not be found ===
=== Screen 1 could not be found ===
Line 182: Line 198:
=== Redshift works fine when invoked as a command but fails when run as a systemd service ===
=== Redshift works fine when invoked as a command but fails when run as a systemd service ===


The [[systemd]] unit has a line in the {{ic|redshift.service}} file that makes the service wait until the {{ic|display-manager.service}} unit is started by a [[display manager]] before the unit will invoke {{ic|redshift}}. If you do not use a display manager, [[edit]] the {{ic|redshift.service}} user service and delete the {{ic|1=After=display-manager.service}} line. Run {{ic|systemctl --user daemon-reload}} and the service should initialize properly.
The [[systemd]] unit has a line in the {{ic|redshift.service}} file that makes the service wait until the {{ic|display-manager.service}} unit is started by a [[display manager]] before the unit will invoke {{ic|redshift}}. If you do not use a display manager, [[edit]] the {{ic|redshift.service}} user service and delete the {{ic|1=After=display-manager.service}} line. Run a [[daemon-reload]] and the service should initialize properly.


=== Redshift temporarily resets using some wine apps that reset gamma values ===
=== Redshift-gtk service causes core-dumping ===


If you notice that using some wine apps, redshift seems to reset temporarily upon launch, or adjusting settings, or etc, then there is a useful registry key that seems to alleviate this. See [https://www.winehq.org/pipermail/wine-bugs/2015-January/403770.html] and [https://wiki.winehq.org/UsefulRegistryKeys]. Set or create the string value
Refer to the previous problem and to [https://github.com/jonls/redshift/issues/265].


{{hc|HKEY_CURRENT_USER\Software\Wine\X11 Driver|2=
=== Redshift does not appear in system tray ===
UseXVidMode="N"
}}


using the registry editor, or import/set it otherwise.
If running the {{ic|$ redshift-gtk}} command does not start in the system tray, but instead you get the following output


=== Redshift GDBus.Error:org.freedesktop.DBus.Error.AccessDenied on start ===
{{hc|$ redshift-gtk|
Traceback (most recent call last):
  File "/usr/bin/redshift-gtk", line 26, in <module>
    from redshift_gtk.statusicon import run
  File "/usr/lib/python3.8/site-packages/redshift_gtk/statusicon.py", line 31, in <module>
    gi.require_version('Gtk', '3.0')
AttributeError: module 'gi' has no attribute 'require_version'
}}


If running {{ic|$ redshift}} and you are getting:
you will need to install {{Pkg|python-gobject}}.


{{hc|$ redshift|
=== Redshift temporarily resets using some wine applications that reset gamma values ===
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Unable to start GeoClue client: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: 'redshift' disallowed, no agent for UID 1000.
Unable to connect to GeoClue.
Unable to get location from provider.
}}


or running {{ic|$ redshift-gtk}} and getting the similar error:
If you notice that using some wine applications, redshift seems to reset temporarily upon launch, or adjusting settings, or etc, then there is a useful registry key that seems to alleviate this. See [https://www.winehq.org/pipermail/wine-bugs/2015-January/403770.html] and [https://wiki.winehq.org/UsefulRegistryKeys]. Set or create the string value


{{hc|$ redshift-gtk|
{{hc|HKEY_CURRENT_USER\Software\Wine\X11 Driver|2=
Failed to run Redshift
UseXVidMode="N"
Trying location provider `geoclue2'...
Unable to start GeoClue client:
GDBus.Error:org.freedesktop.DBus.Error.AccessDenied:
'redshift' disallowed, no agent for UID 1000.
Unable to connect to GeoClue.
Unable to get location from provider.
}}
}}


You can create a [[systemd]] unit file in {{ic|~/.config/systemd/user/geoclue-agent.service}} with the following config:
using the registry editor, or import/set it otherwise.


{{hc|~/.config/systemd/user/geoclue-agent.service|2=
=== Redshift turns the screen green when resolution is over 1080p while using Nvidia drivers ===
[Unit]
Description=redshift needs to get a (geo)clue


[Service]
This is a bug with the nvidia drivers. A fix for this is to make the following edit:
ExecStart=/usr/lib/geoclue-2.0/demos/agent


[Install]
{{hc|/etc/X11/xorg.conf.d/20-nvidia.conf|2=
WantedBy=default.target
Section "Device"
    ...
    Option        "UseNvKmsCompositionPipeline" "false"
    ...
EndSection
}}
}}


Start and enable the service with systemctl: {{ic|$ systemctl --user enable --now geoclue-agent.service}} and try running redshift again.
For more information, see [https://github.com/jonls/redshift/issues/587 redshift issue 587] and [https://github.com/jonls/redshift/issues/720 redshift issue 720].


If you still get the same error, it may be because of geoclue being locked down to a few programs by default. Try adding the following lines to {{ic|/etc/geoclue/geoclue.conf}} (see [https://github.com/jonls/redshift/issues/158#issuecomment-71329118 redshift issue 158] and {{Bug|40360}}) and run {{ic|$ redshift}} again:
=== Redshift does not support hotkey for toggling ===


{{hc|/etc/geoclue/geoclue.conf|2=
A workaround is to create a custom hotkey in your desktop environment calling the command {{ic|pkill -USR1 '^redshift$'}}.
[redshift]
 
allowed=true
For more information, see [https://github.com/jonls/redshift/issues/186#issuecomment-96220548].
system=false
users=
}}


== See also ==
== See also ==


* [http://jonls.dk/redshift Redshift website]
* [http://jonls.dk/redshift Redshift website]
* [http://github.com/jonls/redshift Redshift on github]
* [https://github.com/jonls/redshift Redshift on GitHub]
* [[Wikipedia:Redshift (software)]]
* [[Wikipedia:Redshift (software)]]
* Similar software: [https://github.com/jumper149/blugon] {{AUR|blugon}}, {{AUR|xflux-gui-git}}
* Similar software: {{AUR|redshift-scheduler}}, {{AUR|blugon}}

Latest revision as of 10:38, 25 February 2024

From the Redshift project web page:

Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night. This program is inspired by the closed-source application f.lux.
Note: Redshift does not support Wayland [1]. See Backlight#Wayland for alternatives.

Installation

Install the redshift package. Alternatively, install the redshift-minimalAUR package, for a version with minimal dependencies.

Front ends

The redshift-gtk command comes with the redshift package and provides a system tray icon for controlling Redshift. See optional dependencies.

Alternatives are redshift-qtAUR, redshiftconfAUR or plasma5-applets-redshift-control-gitAUR.

Usage

Redshift will at least need your location to start (unless -O is used), meaning the latitude and longitude of your location. Redshift employs several routines for obtaining your location. If none of them works (e.g. none of the used helper programs is installed), you need to enter your location manually.

Quick start

To just get it up and running with a basic setup, issue:

$ redshift -l LATITUDE:LONGITUDE

where LATITUDE is the latitude and LONGITUDE is the longitude of your location.

Tip: You can get the coordinates of a place with GeoNames.org.

To instantly adjust the color temperature of your screen use:

$ redshift -P -O TEMPERATURE

where TEMPERATURE is the desired color temperature (between 1000 and 25000).

Autostart

There are several options to have Redshift automatically started:

  • By right-clicking the system tray icon and selecting Autostart when redshift-gtk or plasma5-applets-redshift-control is already launched.
  • By placing a Redshift desktop entry in ~/.config/autostart/ or by adding redshift to your window manager or desktop environment's autostarting method.
  • By using the user units provided: redshift.service and redshift-gtk.service. Activate only one of them depending on whether or not you want the system tray icon.
Note:
  • The Redshift service files contain Restart=always so they will restart infinitely. See systemd.service(5).
  • When using a systemd user service, Xorg must be started before execution of the service, which is not the case without a display manager. Otherwise you will get RANDR Query Version' returned error -1 and Initialization of randr failed. This is already accounted for in the systemd/User method above, which contains After=display-manager.service.

Toggle

Redshift will continously update the color temperature at regular intervals. One shot mode can be selected if you only want to do one adjustment. The color adjustments done by Redshift can be temporarily toggled on and off by sending it the USR1 signal:

$ pkill -USR1 redshift

Configuration

Redshift reads the configuration file ~/.config/redshift/redshift.conf [2] if it exists. However, Redshift does not create that configuration file, so you may want to create it manually. See redshift.conf.sample.

Specify location manually

Redshift calculates the sunrise and sunset times based on geographic coordinates. It can be specified manually by using the manual location-provider, e.g. for Paris:

~/.config/redshift/redshift.conf
[redshift]
...
location-provider=manual
...
[manual]
lat=48.864716
lon=2.349014

Automatic location based on GeoClue

Redshift uses the geoclue2 location-provider by default. It needs a GeoClue agent running in the background. It is supposed to work without further configuration, but if you experience problems, see #Unable to connect to GeoClue.

Automatic location based on Mozilla Location Service

You can use cURL to get the location data and parse it into the format required by Redshift. For example, Mozilla provides json location data that can be parsed with jq as follows:

redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | jq -r '"\(.location.lat):\(.location.lng)"')

or with awk if jq is not on the system:

redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | awk 'OFS=":" {print $3,$5}' | tr -d ',}')

or with sed:

redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | sed 's/.*"lat": \(-\?[0-9.]*\).*"lng": \(-\?[0-9.]*\).*/\1:\2/')

Automatic location based on GPSD

You can also use gpsd to automatically determine your GPS location and use it as an input for Redshift. Create the following script and pass $lat and $lon to redshift -l $lat;$lon:

#!/bin/bash
date
#gpsdata=$( gpspipe -w -n 10 |   grep -m 1 lon )
gpsdata=$( gpspipe -w | grep -m 1 TPV )
lat=$( echo "$gpsdata"  | jsawk 'return this.lat' )
lon=$( echo "$gpsdata"  | jsawk 'return this.lon' )
alt=$( echo "$gpsdata"  | jsawk 'return this.alt' )
dt=$( echo "$gpsdata" | jsawk 'return this.time' )
echo "$dt"
echo "You are here: $lat, $lon at $alt"

For more information, see this forums thread.

Use real screen brightness

Redshift has a brightness adjustment setting, but it does not work the way most people might expect. In fact it is a fake brightness adjustment obtained by manipulating the gamma ramps, which means that it does not reduce the backlight of the screen. [3]

Changing screen backlight is possible with redshift hooks and acpilight, but please see Backlight#xbacklight as there are some limitations and you may have to find another method of controlling the backlight depending on your hardware.

You need to create a file in ~/.config/redshift/hooks and make it executable. You can use and edit the following example:

~/.config/redshift/hooks/brightness.sh
#!/bin/sh
# Set brightness via xbrightness when redshift status changes

# Set brightness values for each status.
# Range from 1 to 100 is valid
brightness_day=85
brightness_transition=50
brightness_night=30
# Set fps for smoooooth transition
fps=1000
# Adjust this grep to filter only the backlights you want to adjust
backlights=($(xbacklight -list | grep ddcci*))

set_brightness() {
	for backlight in "${backlights[@]}"
	do
		xbacklight -set $1 -fps $fps -ctrl $backlight &
	done
}

if [ "$1" = period-changed ]; then
	case $3 in
		night)
			set_brightness $brightness_night 
			;;
		transition)
			set_brightness $brightness_transition
			;;
		daytime)
			set_brightness $brightness_day
			;;
	esac
fi

Make it executable and restart the redshift.service to apply changes.

Check the service status as it should not contain the following message:

redshift[..]: No outputs have backlight property

Troubleshooting

Unable to connect to GeoClue

If running $ redshift and you are getting:

Unable to obtain GeoClue client path: Timeout was reached.

Then make sure that a GeoClue agent is running. GNOME Shell provides an agent itself. For other desktop environments, a demo agent (/usr/lib/geoclue-2.0/demos/agent) is autostarted. You can check if GeoClue works properly by checking the output of the /usr/lib/geoclue-2.0/demos/where-am-i command.

If you are using a desktop environment that does not support XDG Autostart, then you have to start the demo agent manually, or you can create a systemd unit file with the following config:

~/.config/systemd/user/geoclue-agent.service
[Unit]
Description=redshift needs to get a (geo)clue

[Service]
ExecStart=/usr/lib/geoclue-2.0/demos/agent

[Install]
WantedBy=default.target

Then start/enable the geoclue-agent.service user unit.

Screen 1 could not be found

Locate configuration-file "redshift.conf" in your distribution and change "screen 1" to "screen 0".

Left/right clicking the tray icon does not work

Install libappindicator-gtk3. See redshift issue 363 and FS#49971.

Redshift makes the screen quickly flicker between the set color value of the screen and the default color value

Make sure there are not multiple instances of redshift running.

Redshift works fine when invoked as a command but fails when run as a systemd service

The systemd unit has a line in the redshift.service file that makes the service wait until the display-manager.service unit is started by a display manager before the unit will invoke redshift. If you do not use a display manager, edit the redshift.service user service and delete the After=display-manager.service line. Run a daemon-reload and the service should initialize properly.

Redshift-gtk service causes core-dumping

Refer to the previous problem and to [4].

Redshift does not appear in system tray

If running the $ redshift-gtk command does not start in the system tray, but instead you get the following output

$ redshift-gtk
Traceback (most recent call last):
  File "/usr/bin/redshift-gtk", line 26, in <module>
    from redshift_gtk.statusicon import run
  File "/usr/lib/python3.8/site-packages/redshift_gtk/statusicon.py", line 31, in <module>
    gi.require_version('Gtk', '3.0')
AttributeError: module 'gi' has no attribute 'require_version'

you will need to install python-gobject.

Redshift temporarily resets using some wine applications that reset gamma values

If you notice that using some wine applications, redshift seems to reset temporarily upon launch, or adjusting settings, or etc, then there is a useful registry key that seems to alleviate this. See [5] and [6]. Set or create the string value

HKEY_CURRENT_USER\Software\Wine\X11 Driver
UseXVidMode="N"

using the registry editor, or import/set it otherwise.

Redshift turns the screen green when resolution is over 1080p while using Nvidia drivers

This is a bug with the nvidia drivers. A fix for this is to make the following edit:

/etc/X11/xorg.conf.d/20-nvidia.conf
Section "Device"
    ...
    Option         "UseNvKmsCompositionPipeline" "false"
    ...
EndSection

For more information, see redshift issue 587 and redshift issue 720.

Redshift does not support hotkey for toggling

A workaround is to create a custom hotkey in your desktop environment calling the command pkill -USR1 '^redshift$'.

For more information, see [7].

See also