Difference between revisions of "Redshift"

From ArchWiki
Jump to: navigation, search
(Manual setup)
m (add external link to wikipedia page)
 
(115 intermediate revisions by 58 users not shown)
Line 1: Line 1:
[[Category:X Server]]
+
[[Category:X server]]
 
[[Category:Graphics]]
 
[[Category:Graphics]]
 
[[Category:Eye candy]]
 
[[Category:Eye candy]]
[[Category:Audio/Video]]
+
[[ja:Redshift]]
{{Article summary start}}
+
[[ru:Redshift]]
{{Article summary text|Installation, configuration, tips & tricks and basic troubleshooting of Redshift - A program that shifts the screen color temperature according to the position of the sun.}}
+
From the [http://jonls.dk/redshift/ Redshift project web page]:
{{Article summary heading|Other sources}}
 
{{Article summary text|[http://jonls.dk/redshift Redshift website]}}
 
{{Article summary text|[https://launchpad.net/redshift Redshift on launchpad]}}
 
{{Article summary end}}
 
  
The [https://launchpad.net/redshift website] states:
+
: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].
  
"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] [...]."
+
{{Note|
 +
* Redshift does not support [[Wayland]] since it offers no way to adjust the color temperature. [https://github.com/jonls/redshift/issues/55]
 +
* [[GNOME]] provides features like Redshift out-of-the-box and has [[Wayland]] support.
 +
}}
 +
 
 +
== Installation ==
 +
 
 +
=== Redshift ===
 +
 
 +
[[Install]] the {{Pkg|redshift}} package. Alternatively, install the {{AUR|redshift-minimal}} package, for a version with minimal dependencies.
  
The project is developed on [https://launchpad.net/redshift launchpad].
+
==== Redshift-GTK ====
  
== Installation ==
+
The {{ic|redshift-gtk}} command is provided by the {{Pkg|redshift}} package. Redshift-GTK provides a system tray icon for controlling Redshift and requires the following packages to be installed: {{Pkg|python-gobject}}, {{Pkg|python-xdg}}, and {{Pkg|librsvg}}.
  
The {{Pkg|redshift}} package is available in the [[Official Repositories]].
+
===== Alternatives =====
  
{{Note|If Redshift will not start, see section [[#Troubleshooting]].}}
+
Another GTK application is {{AUR|redshiftgui-bin}} and alternative Qt solutions available are {{AUR|redshift-qt}}, {{AUR|redshiftconf}} or {{AUR|plasma5-applets-redshift-control-git}}.
  
 
== Configuration ==
 
== Configuration ==
  
 
Redshift will at least need your location to start, 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: For most places/cities an easy way is to look up the wikipedia page of that place and get the location from there (search the page for "coordinates").
 
Redshift will at least need your location to start, 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: For most places/cities an easy way is to look up the wikipedia page of that place and get the location from there (search the page for "coordinates").
 +
 +
=== Autostart ===
 +
 +
There are several options to have redshift automatically started:
 +
 +
* By launching redshift with a script under {{ic|/etc/X11/xinit/xinitrc.d/}}.
 +
* By adding {{ic|pgrep redshift &> /dev/null <nowiki>||</nowiki> redshift &> /dev/null &}} to {{ic|~/.xinitrc}} if you are using {{ic|startx}}
 +
* By using the provided [[Systemd#Using units|systemd service unit files]]. Be careful: the service can only be started in user mode, see [[systemd/User#Basic setup]]. Two service files are provided: {{ic|/usr/lib/systemd/user/redshift.service}} and {{ic|/usr/lib/systemd/user/redshift-gtk.service}}. Activate only one of them depending on whether or not you want the system tray icon. The {{ic|DISPLAY}} environment variable needs to be configured. See [[systemd/User#DISPLAY and XAUTHORITY]].
 +
* By right-clicking the system tray icon when redshift-gtk or plasma5-applets-redshift-control is already launched and selecting 'Autostart'.
 +
{{note|The redshift services files contains {{ic|Restart<nowiki>=</nowiki>always}} so the service will restart infinitely (see {{man|5|systemd.service}}) }}
 +
* By using your preferred window manager or desktop environment's autostart methods. For example in i3, the following line could be added to the config file: {{ic|exec --no-startup-id redshift-gtk}}. On other desktop environments, [[Desktop entries]] inside {{Ic|~/.config/autostart}} can be used.
  
 
=== Quick start ===
 
=== Quick start ===
 +
{{Tip|You can get the coordinates of a place with [http://www.geonames.org/ GeoNames.org].}}
  
 
To just get it up and running with a basic setup, issue:
 
To just get it up and running with a basic setup, issue:
Line 33: Line 50:
  
 
where LAT is the latitude and LON is the longitude of your location.
 
where LAT is the latitude and LON is the longitude of your location.
 +
 +
=== Automatic location based on GPS ===
 +
 +
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}}:
 +
 +
#!/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 [https://bbs.archlinux.org/viewtopic.php?pid=1389735#p1389735 this] forums thread.
  
 
=== Manual setup ===
 
=== Manual setup ===
  
 
Redshift reads the configuration file {{ic|~/.config/redshift.conf}}, if it exists. However, Redshift does not create that configuration file, so you have to create it manually.
 
Redshift reads the configuration file {{ic|~/.config/redshift.conf}}, if it exists. However, Redshift does not create that configuration file, so you have to create it manually.
Example for Hamburg/Germany:
+
Below is an example (copied from the [http://jonls.dk/redshift/ Redshift website]).
  
{{hc|~/.config/redshift.conf|
+
{{note|There seems to be a bug in Redshift that causes the transition option in the configuration file to not work as described: Instead of handling the transition between day and night it '''only''' changes the transition between application start-up and shutdown (and delay the latter as a consequence). See the [[talk:redshift#Day and night transition|talk page]] and the [https://github.com/jonls/redshift/issues/270 issue on the Redshift project page] for more information.}}
; Global settings
+
 
 +
{{hc|~/.config/redshift.conf|2=
 +
; Global settings for redshift
 
[redshift]
 
[redshift]
temp-day&#61;5700
+
; Set the day and night screen temperatures (Neutral is 6500K)
temp-night&#61;3500
+
temp-day=5700
transition&#61;1
+
temp-night=3500
gamma&#61;0.8:0.7:0.8
 
location-provider&#61;manual
 
adjustment-method&#61;vidmode
 
  
; The location provider and adjustment method settings
+
; Enable/Disable a smooth transition between day and night
; are in their own sections.
+
; 0 will cause a direct change from day to night screen temperature.
 +
; 1 will gradually increase or decrease the screen temperature.
 +
transition=1
 +
 
 +
; Set the screen brightness. Default is 1.0.
 +
;brightness=0.9
 +
; It is also possible to use different settings for day and night
 +
; since version 1.8.
 +
;brightness-day=0.7
 +
;brightness-night=0.4
 +
; Set the screen gamma (for all colors, or each color channel
 +
; individually)
 +
gamma=0.8
 +
;gamma=0.8:0.7:0.8
 +
; This can also be set individually for day and night since
 +
; version 1.10.
 +
;gamma-day=0.8:0.7:0.8
 +
;gamma-night=0.6
 +
 
 +
; Set the location-provider: 'geoclue2' or 'manual'
 +
; type 'redshift -l list' to see possible values.
 +
; The location provider settings are in a different section.
 +
location-provider=manual
 +
 
 +
; Set the adjustment-method: 'randr', 'vidmode'
 +
; type 'redshift -m list' to see all possible values.
 +
; 'randr' is the preferred method, 'vidmode' is an older API.
 +
; but works in some cases when 'randr' does not.
 +
; The adjustment method settings are in a different section.
 +
adjustment-method=randr
 +
 
 +
; Configuration of the location-provider:
 +
; type 'redshift -l PROVIDER:help' to see the settings.
 +
; ex: 'redshift -l manual:help'
 +
; Keep in mind that longitudes west of Greenwich (e.g. the Americas)
 +
; are negative numbers.
 
[manual]
 
[manual]
; Hamburg
+
lat=48.1
lat&#61;53.3
+
lon=11.6
lon&#61;10.0
+
 
 +
; Configuration of the adjustment-method
 +
; type 'redshift -m METHOD:help' to see the settings.
 +
; ex: 'redshift -m randr:help'
 +
; In this example, randr is configured to adjust screen 1.
 +
; Note that the numbering starts from 0, so this is actually the
 +
; second screen. If this option is not specified, Redshift will try
 +
; to adjust _all_ screens.
 +
[randr]
 +
screen=1
 +
}}
 +
 
 +
=== 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. [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.
 +
 
 +
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
  
; In this example screen 1 is adjusted by vidmode. Note
+
Create and adjust the following script:
; that the numbering starts from 0, so this is actually
+
{{hc|
; the second screen.
+
~/.config/redshift/hooks/brightness.sh|output=#!/bin/sh
[vidmode]
+
 
screen&#61;0
+
# Set brightness via xbrightness when redshift status changes
screen&#61;1
+
 
 +
# Set brightness values for each status.
 +
# Range from 1 to 100 is valid
 +
brightness_day="100"
 +
brightness_transition="50"
 +
brightness_night="10"
 +
# Set fade time for changes to one minute
 +
fade_time=60000
 +
 
 +
case $1 in
 +
period-changed)
 +
case $3 in
 +
night)
 +
xbacklight -set $brightness_night -time $fade_time
 +
;;
 +
transition)
 +
xbacklight -set $brightness_transition -time $fade_time
 +
;;
 +
daytime)
 +
xbacklight -set $brightness_day -time $fade_time
 +
;;
 +
esac
 +
;;
 +
esac
 
}}
 
}}
  
After you created that file, start redshift from the menu of your DE (called "gtk-redshift") or type the following in your terminal:
+
Make it executable:
  
  $ redshift-gtk &
+
$ chmod +x ~/.config/redshift/hooks/brightness.sh
  
Using "redshift-gtk" instead of "redshift" launches Redshift with a system tray icon for easier handling of the application.
+
[[Restart]] the {{ic|redshift.service}} [[user]] to apply changes.
Finally, if you want to start Redshift automatically on system startup, rightclick the system tray icon an check "Autostart".
+
 
 +
Check the service status as it should '''not''' contain the following message:
 +
 
 +
redshift[..]: No outputs have backlight property
  
 
== Troubleshooting ==
 
== Troubleshooting ==
  
=== Missing dependency ===
+
=== 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 doesn't work ===
 +
Install {{Pkg|libappindicator-gtk3}}. See [https://github.com/jonls/redshift/issues/363] and [https://bugs.archlinux.org/task/49971]
 +
 
 +
=== Failed to run Redshift due to geoclue2 ===
 +
{{note|Prior to apply the method below, close redshift-gtk and restart the geoclue service. Sometimes the location service fails due to e.g. connection established after the location service.}}
 +
 
 +
If using [[GNOME]], you can also toggle Location Services to "On" in "Settings -> Privacy"
 +
 
 +
By default, the geoclue2 configuration files does not allow Redshift access.
 +
In order to allow access, add the following lines to {{ic|/etc/geoclue/geoclue.conf}}
 +
{{hc|/etc/geoclue/geoclue.conf|2=
 +
[redshift]
 +
allowed=true
 +
system=false
 +
users=
 +
}}
 +
=== Redshift temporarily resets using some wine apps that reset gamma values ===
 +
 
 +
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
 +
{{hc|HKEY_CURRENT_USER\Software\Wine\X11 Driver|2=UseXVidMode="N"}} using the registry editor, or import/set it otherwise.
  
{{Pkg|python2-xdg}}, {{Pkg|librsvg}} and {{Pkg|pygtk}} are needed for gtk-redshift. They are the optional dependencies for the redshift package. If you run into problems when trying to run gtk-redshift, check if they are installed. If they are not installed, install them as a dependency:
+
== See also ==
  # pacman --asdeps -S python2-xdg librsvg pygtk
+
* [http://jonls.dk/redshift Redshift website]
 +
* [http://github.com/jonls/redshift Redshift on github]
 +
* {{App|sct|set color temperature|{{AUR|sct}}|{{AUR|sct}}}}
 +
* {{AUR|xflux-gui-git}}
 +
* [[Wikipedia:Redshift_(software)]]

Latest revision as of 02:05, 14 November 2017

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 f.lux.
Note:
  • Redshift does not support Wayland since it offers no way to adjust the color temperature. [1]
  • GNOME provides features like Redshift out-of-the-box and has Wayland support.

Installation

Redshift

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

Redshift-GTK

The redshift-gtk command is provided by the redshift package. Redshift-GTK provides a system tray icon for controlling Redshift and requires the following packages to be installed: python-gobject, python-xdg, and librsvg.

Alternatives

Another GTK application is redshiftgui-binAUR and alternative Qt solutions available are redshift-qtAUR, redshiftconfAUR or plasma5-applets-redshift-control-gitAUR.

Configuration

Redshift will at least need your location to start, 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: For most places/cities an easy way is to look up the wikipedia page of that place and get the location from there (search the page for "coordinates").

Autostart

There are several options to have redshift automatically started:

  • By launching redshift with a script under /etc/X11/xinit/xinitrc.d/.
  • By adding pgrep redshift &> /dev/null || redshift &> /dev/null & to ~/.xinitrc if you are using startx
  • By using the provided systemd service unit files. Be careful: the service can only be started in user mode, see systemd/User#Basic setup. Two service files are provided: /usr/lib/systemd/user/redshift.service and /usr/lib/systemd/user/redshift-gtk.service. Activate only one of them depending on whether or not you want the system tray icon. The DISPLAY environment variable needs to be configured. See systemd/User#DISPLAY and XAUTHORITY.
  • By right-clicking the system tray icon when redshift-gtk or plasma5-applets-redshift-control is already launched and selecting 'Autostart'.
Note: The redshift services files contains Restart=always so the service will restart infinitely (see systemd.service(5))
  • By using your preferred window manager or desktop environment's autostart methods. For example in i3, the following line could be added to the config file: exec --no-startup-id redshift-gtk. On other desktop environments, Desktop entries inside ~/.config/autostart can be used.

Quick start

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

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

 $ redshift -l LAT:LON

where LAT is the latitude and LON is the longitude of your location.

Automatic location based on GPS

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.

Manual setup

Redshift reads the configuration file ~/.config/redshift.conf, if it exists. However, Redshift does not create that configuration file, so you have to create it manually. Below is an example (copied from the Redshift website).

Note: There seems to be a bug in Redshift that causes the transition option in the configuration file to not work as described: Instead of handling the transition between day and night it only changes the transition between application start-up and shutdown (and delay the latter as a consequence). See the talk page and the issue on the Redshift project page for more information.
~/.config/redshift.conf
; Global settings for redshift
[redshift]
; Set the day and night screen temperatures (Neutral is 6500K)
temp-day=5700
temp-night=3500

; Enable/Disable a smooth transition between day and night
; 0 will cause a direct change from day to night screen temperature.
; 1 will gradually increase or decrease the screen temperature.
transition=1

; Set the screen brightness. Default is 1.0.
;brightness=0.9
; It is also possible to use different settings for day and night
; since version 1.8.
;brightness-day=0.7
;brightness-night=0.4
; Set the screen gamma (for all colors, or each color channel
; individually)
gamma=0.8
;gamma=0.8:0.7:0.8
; This can also be set individually for day and night since
; version 1.10.
;gamma-day=0.8:0.7:0.8
;gamma-night=0.6

; Set the location-provider: 'geoclue2' or 'manual'
; type 'redshift -l list' to see possible values.
; The location provider settings are in a different section.
location-provider=manual

; Set the adjustment-method: 'randr', 'vidmode'
; type 'redshift -m list' to see all possible values.
; 'randr' is the preferred method, 'vidmode' is an older API.
; but works in some cases when 'randr' does not.
; The adjustment method settings are in a different section.
adjustment-method=randr

; Configuration of the location-provider:
; type 'redshift -l PROVIDER:help' to see the settings.
; ex: 'redshift -l manual:help'
; Keep in mind that longitudes west of Greenwich (e.g. the Americas)
; are negative numbers.
[manual]
lat=48.1
lon=11.6

; Configuration of the adjustment-method
; type 'redshift -m METHOD:help' to see the settings.
; ex: 'redshift -m randr:help'
; In this example, randr is configured to adjust screen 1.
; Note that the numbering starts from 0, so this is actually the
; second screen. If this option is not specified, Redshift will try
; to adjust _all_ screens.
[randr]
screen=1

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. [2]

Changing screen backlight is possible with redshift hooks and xorg-xrandr and 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.

You need to create a file in ~/.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:

~/.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="100"
brightness_transition="50"
brightness_night="10"
# Set fade time for changes to one minute
fade_time=60000

case $1 in
	period-changed)
		case $3 in
			night)
				xbacklight -set $brightness_night -time $fade_time
				;;
			transition)
				xbacklight -set $brightness_transition -time $fade_time
				;;
			daytime)
				xbacklight -set $brightness_day -time $fade_time
				;;
		esac
		;;
esac

Make it executable:

$ chmod +x ~/.config/redshift/hooks/brightness.sh

Restart the redshift.service user to apply changes.

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

redshift[..]: No outputs have backlight property

Troubleshooting

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 doesn't work

Install libappindicator-gtk3. See [3] and [4]

Failed to run Redshift due to geoclue2

Note: Prior to apply the method below, close redshift-gtk and restart the geoclue service. Sometimes the location service fails due to e.g. connection established after the location service.

If using GNOME, you can also toggle Location Services to "On" in "Settings -> Privacy"

By default, the geoclue2 configuration files does not allow Redshift access. In order to allow access, add the following lines to /etc/geoclue/geoclue.conf

/etc/geoclue/geoclue.conf
[redshift]
allowed=true
system=false
users=

Redshift temporarily resets using some wine apps that reset gamma values

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 [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.

See also

sctAUR || sctAUR