Redshift (简体中文)

From ArchWiki
Jump to navigation Jump to search
翻译状态:本文是 Redshift翻译。上次翻译日期:2019-6-12。如果英文版本有所更改,则您可以帮助同步翻译。

来自 Redshift project web page:

Redshift 会根据你的周围环境调节屏幕色温,如果你晚上在屏幕前工作,这可能帮助你减少对眼睛的伤害。 这个程序启发于 f.lux
注意: Redshift 不支持 Wayland 因为它无法调节色温 [1]。查看 Backlight#Wayland 了解更多。


安装 redshift 包。或者安装 redshift-minimalAUR 包(最小依赖版本)。


redshift-gtk 命令 来自 redshift 包 提供托盘图标用于控制 Redshift。 请参阅可选的依赖。

另外,也可以使用这些前端 redshiftgui-binAUR (GTK) 和 redshift-qtAUR, redshiftconfAUR 或者 和 plasma5-applets-redshift-control-gitAUR (Qt)。


Redshift 需要你的位置才能开始运行 (除非使用 -O 选项),即需要你所在位置的经纬度。Redshift 使用一些程序获得你的位置。如果这些程序不工作 (比如这些程序都没有安装), 你需要手动输入你的位置。




LATITUDE 为所在位置的维度 , LONGITUDE 为所在位置的经度。


$ redshift -P -O TEMPERATURE

TEMPERATURE 为期望的色温值 (介于 100025000 之间)。



  • 鼠标右键点击托盘图标选择 Autostartredshift-gtk 或者 plasma5-applets-redshift-control 已经启动的时候。
  • 放置 Redshift Desktop entry~/.config/autostart/ 或通过添加 redshift 到你的窗口管理器或者桌面环境的 Autostarting 方法中。
  • 使用 Systemd/User。 软件提供了两个 srvices: redshift.serviceredshift-gtk.service。激活哪一个服务取决于你是否想要显示系统托盘图表。
  • 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.


Redshift 会读取配置文件 ~/.config/redshift/redshift.conf [2] (如果该文件存在的话)。 然而,Redshift 不会自动创建这个文件, 因此你可能需要手动创建它。配置文件示例:redshift.conf.sample

Automatic location based on GeoClue2

In order to allow access Redshift to use GeoClue2, add the following lines to /etc/geoclue/geoclue.conf:


Restart redshift.service and/or any other Redshift instance to apply the changes.

  • 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 [3], it may be required to use the manual location-provider instead, e.g. for Paris:
; Set the location-provider: 'geoclue2', 'manual'
; type 'redshift -l list' to see possible values.
; The location provider settings are in a different section.


; Keep in mind that longitudes west of Greenwich (e.g. the Americas)
; are negative numbers.
  • If using i3wm or similar, you will also need to enable the geoclue agent on startup. As well as systemctl --user enable redshift-gtk or redshift user service.
exec --no-startup-id /usr/lib/geoclue-2.0/demos/agent

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:

#gpsdata=$( gpspipe -w -n 10 |   grep -m 1 lon )
gpsdata=$( gpspipe -w | grep -m 1 TPV )
lat=$( echo "$gpsdata"  | jsawk 'return' )
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. [4]

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:


# Set brightness via xbrightness when redshift status changes

# Set brightness values for each status.
# Range from 1 to 100 is valid
# Set fade time for changes to one minute

if [ "$1" = period-changed ]; then
	case $3 in
			xbacklight -set $brightness_night -time $fade_time
			xbacklight -set $brightness_transition -time $fade_time
			xbacklight -set $brightness_day -time $fade_time

Make it executable:

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

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


Screen 1 could not be found

修改配置文件 "redshift.conf" 将 "screen 1" 改为 "screen 0"。


安装 libappindicator-gtk3。 请看 redshift issue 363 and FS#49971.

Redshift 让屏幕在设置的色温值和默认的色温值之间快速闪烁


Redshift 使用命令启动时可以工作 但是以 systemd service 启动失败

systemd unit 有一行在 redshift.service 文件中,要求必须在display-manager.service unit 被一个显示管理器 display manager 启动后才能启动。 如果你不使用显示管理器, 编辑 redshift.service 用户服务文件删除 After=display-manager.service 行. 运行 systemctl --user daemon-reload 后服务应该会正确初始化。

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

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

Redshift GDBus.Error:org.freedesktop.DBus.Error.AccessDenied on start

If running $ redshift and you are getting:

$ redshift
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 $ redshift-gtk and getting the similar error:

$ redshift-gtk
Failed to run Redshift
Trying location provider `geoclue2'...
Unable to start GeoClue client:
'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 ~/.config/systemd/user/geoclue-agent.service with the following config:

Description=redshift needs to get a (geo)clue



Start and enable the service with systemctl: $ systemctl --user enable --now geoclue-agent.service and try running redshift again.

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 /etc/geoclue/geoclue.conf (see redshift issue 158 and FS#40360) and run $ redshift again: