出自 Arch Linux 中文维基

Tango-view-refresh-red.png本文內容或本節內容已經過期。Tango-view-refresh-red.png

原因: 請提供模板的第一個位置參數以概括原因。 (在Talk:Redshift討論)

來自 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 使用一些程序獲得你的位置。如果這些程序不工作 (比如這些程序都沒有安裝), 你需要手動輸入你的位置。

快速開始

以基本的設置啟動:

$ redshift -l LATITUDE:LONGITUDE

LATITUDE 為所在位置的維度 , LONGITUDE 為所在位置的經度。

立即更改屏幕色溫:

$ redshift -P -O TEMPERATURE

TEMPERATURE 為期望的色溫值 (介於 100025000 之間)。

自動啟動

有幾個選項可以自動啟動Redshif:

  • 滑鼠右鍵點擊托盤圖標選擇 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:

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

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:
~/.config/redshift/redshift.conf
[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

...

; Keep in mind that longitudes west of Greenwich (e.g. the Americas)
; are negative numbers.
[manual]
lat=48.853
lon=2.349
  • 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.
~/.i3/config
...
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:

#!/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. [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:

~/.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

if [ "$1" = period-changed ]; then
	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
fi

Make it executable:

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

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實例在同時運行。

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
UseXVidMode="N"

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:
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 ~/.config/systemd/user/geoclue-agent.service 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

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:

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

參見