在 Fedora 上使用 Redshift 改善睡眠
Redshift
大多数电子设备发射的蓝光被认为对我们的睡眠有负面影响。作为一个尝试，我们可以在黑暗中不再使用我们的电子设备，以改善我们的睡眠。然而，由于这对我们大多数人并不是很适合，更好的方法是根据你周围环境调整屏幕的色温。实现这一点的最流行的方法之一是使用 Redshift。 Redshift 的创建者 Jon Lund Steffensen 这样描述了他的程序：



> 
> Redshift 会根据你周围的环境调整屏幕的色温。如果你在夜间在屏幕前工作，它可以帮助你减少眼睛伤害。
> 
> 
> 


Redshift 在 Fedora Workstation 上仅工作在 X11 会话中。所以如果你使用 Fedora 24，Redshift 可以工作在默认登录会话中。然而，在 Fedora 25 上，登录的默认会话是 Wayland，因此你将需要替代使用其 GNOME shell 扩展。注意，这个 GNOME Shell 扩展也适用于 X11 会话。


### Redshift 工具


#### 安装


Redshift 在 Fedora 的仓库中，因此我们使用下面的命令安装：



```
sudo dnf install redshift

```

该软件也提供了 GUI。要使用的话就安装 `redshift-gtk`。记住，这个工具只能在 X11 会话中使用：


#### 使用 Redshift 工具


用像下面的命令在命令行中运行：



```
redshift -l 23.6980:133.8807 -t 5600:3400

```

在以上命令中，`-l 23.6980:133.8807` 的意思是我们通知 Redshift 我们当前的位置是南纬 23.6980°，东经 133.8807°。 `-t 5600:3400` 表明你白天想要的色温是 5600，晚上是 3400。


色温与发射的蓝光的量成比例：较低的色温意味着较低量的蓝光。我喜欢在白天使用 5600K（6500K 是中性日光），在晚上使用 3400K（更低的色温让我觉得像盯着番茄一样），但你可以随意尝试。


如果你不指定位置，Redshift 会尝试使用 Geoclue 方法来确定你的位置坐标。如果此方法不起作用，你可以使用几个[网站](http://www.latlong.net/)和在线地图来查找坐标。


![screenshot1](/data/attachment/album/201702/01/180117p6zveubmu25us6uw.png)


别忘记将 Redshift 设置为自动启动，查看 [Jon 的网站](http://jonls.dk/redshift/)来获取更多信息。


### Redshift GNOME Shell 扩展


该程序不能在运行 Wayland 显示服务器（这是 Fedora 25 中的标准）的环境中工作。幸运的是，这里有一个方便的 GNOME Shell 扩展可以做到同样的工作。要安装它，请运行以下命令：



```
sudo dnf copr enable mystro256/gnome-redshift
sudo dnf install gnome-shell-extension-redshift

```

从 COPR 仓库安装后，注销并重新登录你的 Fedora Workstation，然后在 GNOME Tweak 工具中启用它。关于更多信息，请查看 gnome-redshift 的 [copr 仓库](https://copr.fedorainfracloud.org/coprs/mystro256/gnome-redshift/)或 [github 仓库](https://github.com/benzea/gnome-shell-extension-redshift)。


启用扩展后，GNOME shell 右上角会出现一个小小的太阳（或月亮）图标。该扩展还提供了一个设置对话框来调整 redshift 和温度的时间。


![screenshot-from-2017-01-18-15-21-47](/data/attachment/album/201702/01/180118kup8gzo8y9yg0pop.jpg)


### 相关软件


#### F.lux


Redshift 可以被看作是 F.lux 的开源变体。现在有一个 [linux 版本的 F.lux](https://justgetflux.com/linux.html)。如果你不介意使用闭源软件，或者 Redshift 不能正常工作，你可以考虑使用它。


#### Android 版 Twilight


Twilight 与 Redshift 相似，但是用于 Android。它可以让你在晚上在智能手机或平板上阅读更加舒服。


#### Redshift plasmoid


这是 Redshift GUI 的 KDE 版本。你可以在 [github](https://github.com/simgunz/redshift-plasmoid)  中找到更多信息。




---


via: <https://fedoramagazine.org/safe-eyes-redshift/>


作者：[novel](http://novel.id.fedoraproject.org/) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
The blue light emitted by most electronic devices, is known for having a negative impact on our sleep. We could simply quit using each of our electronic devices after dark, as an attempt to improve our sleep. However, since that is not really convenient for most of us, a better way is to adjusts the color temperature of your screen according to your surroundings. One of the most popular ways to achieve this is with the Redshift utility. Jon Lund Steffensen , the creator of Redshift, describes his program in the following way:

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.


The Redshift utility only works in the X11 session on Fedora Workstation. So if you’re using Fedora 24, Redshift will work with the default login session. However, on Fedora 25, the default session at login is Wayland, so you will have to use the GNOME shell extension instead. Note, too that the GNOME Shell extension also works with X11 sessions.

**Redshift utility**


#### Installation

Redshift is in the Fedora’s repos, and thus, all we have to do to install is run this command:

sudo dnf install redshift

The package also provides a GUI. To use this, install

instead. Remember, though, that the utility only works on X11 sessions.

#### Using the Redshift utility

Run the utility from the command line with a command like the following:

redshift -l 23.6980:133.8807 -t 5600:3400

In the above command, the* -l 23.6980:133.8807 *means we are informing Redshift that our current location is 23.6980° S, 133.8807° E. The* -t 5600:3400* declares that during the day you want a colour temperature of 5600, and 3400 at night.

The temperature is proportional to the amount of blue light emitted: a lower temperature, implies a lower amount of blue light. I prefer to use 5600K (6500K is neutral daylight) during the day, and 3400K at night (anything lower makes me feel like I’m staring at a tomato), but feel free to experiment with it.

If you don’t specify a location, Redshift attempts to use the Geoclue method in order to determine your location coordinates. If this method doesn’t work, you could use multiple [websites](http://www.latlong.net) and online maps to find the coordinates.

Don’t forget to set Redshift as an autostart command, and to check [Jon’s website](http://jonls.dk/redshift/) for more information.

## Redshift GNOME Shell extension

The utility does not work when running the Wayland display server (which is standard in Fedora 25). Fortunately, there is a handy GNOME Shell extension that will do the same job. To install, run the the following commands

sudo dnf copr enable mystro256/gnome-redshift sudo dnf install gnome-shell-extension-redshift

After installing from the COPR repo, log out and log back in of your Fedora Workstation, then enable it in the GNOME Tweak tool. For more information, check the gnome-redshift [copr repo](https://copr.fedorainfracloud.org/coprs/mystro256/gnome-redshift/), or the [github repo](https://github.com/benzea/gnome-shell-extension-redshift).

After enabling the extension, a little sun (or moon) icon appears in the top right of your GNOME shell. The extension also provides a settings dialog to tweak the times of the redshift and the temperature.


## Relative software

#### F.lux

Redshift could be seen as the open-source variant of F.lux. There is a [linux version of F.lux](https://justgetflux.com/linux.html) now. You could consider using it if you don’t mind using closed-source software, or if Redshift doesn’t work properly.

#### Twilight for Android

Twilight is similar to Redshift, but for Android. It makes reading on your smartphone or tablet late at night more comfortable.

#### Redshift plasmoid

This is the Redshift GUI version for KDE. You can find more information on [github](https://github.com/simgunz/redshift-plasmoid).
















## Osqui

GNOME Shell extension should be on official repository. This piece of software is a must!

## Diving Deer

For Android there is also Red Moon, https://github.com/raatmarien/red-moon

Unlike Twilight it is open source.

## Be

Thanks for mentioning this. For Android, there is also Yet Another Auto Brightness (YAAB) which automatically adjusts screen brightness to correspond with the amount of light its camera senses. YAAB and Red Moon can be used together by setting “Dim level” to 0% and turning off “Lower brightness” in Red Moon’s settings.

## Dan

Open source alternative to Twilight for Android:

Red Moon

https://f-droid.org/repository/browse/?fdfilter=moon&fdid=com.jmstudios.redmoon

## Daniel

You can use Redshift with Wayland too, but it takes some work for the time being.

## andreppires

Thanks!

## Aaron Lu

Nice. I’ve been using xflux but it stopped working after xorg server updated to 1.19.1. It’s good to know this software and it works for me.

## kapoath

Thank you for the detailed instructions to add Redshift as a Gnome shell extension under Wayland. I needed that!

Works like a charm!

## Ed

I’m also using Redshift on Fedora 24, with no problem. The only gripe I have is that this requieres a internet conenction to work/activate. Without Geoclue it’s helpless.

While back when I was using flux on Ubuntu, once setup,it would work properly even with NO INTERNET .

Making this internet-dependant makes it less practical for people who use computers offline .

## kapoath

I thought that Flatpak could/would solve such issues. For example apps based on specific distro, like f.lux and PacketTracer 7.0 from Cisco that are compatible with Ubuntu, could work in Fedora with the use of Flatpak.

But it doesn’t seem that to be the case.

## cazo

Ed: Setting the provider to ‘manual’ & entering your latitude/longitude allow you to use redshift offline (you can put those values into ~/.config/redshift.conf like:

[redshift]

location-provider=manual

[manual]

lat=55.7

lon=12.6

## Striker

Just FYI: This is not limited to “Fedora Workstation” which is simply just Fedora with Gnome. The article should reflect that this also works on Fedora 25 Plasma 5 default install, which uses X11.

## lupinix

For KDE Plasma the linked plasmoid is outdated… We have an applet for Plasma in official repository: https://apps.fedoraproject.org/packages/plasma-applet-redshift-control

So just dnf install plasma-applet-redshift-control and add it to your panel 😉

## mystro256

I wonder how many people are using my copr. I just popped it on there for personal use and before you know it, I see blog posts popping up.

Note that the GNOME extension works for both Wayland and XOrg, so if you still use X and f.lux or redshift gives you issues, you can always give the extension a shot. For example, I used to use redshift but I found it would flicker a lot.

## Xarchus

Regarding the Redshift GNOME Shell extension; its Github page (https://github.com/benzea/gnome-shell-extension-redshift) explicitly warns users:

I can also see the GNOME bug 741224 still open, which would seem to imply that such a patch is needed. (https://bugzilla.gnome.org/show_bug.cgi?id=741224, left somehow in limbo, with an ambiguous comment from November last year).

So, are the instructions in this post enough to have the GNOME version of redshift working ? If the daemon patching is required, the process is far more involved than the guide above would indicate. Making this clear either way would be very helpful.

## Xarchus

Regarding the “Redshift GNOME Shell extension”: its Github page (https://github.com/benzea/gnome-shell-extension-redshift) warn users that:

Is this sill the case ? If yes, then the steps are far more involved than what the guide above would indicate. Please clarify.

## Ryan Lerch

The copr repo ships a patched version of gnome-settings-daemon:

https://copr.fedorainfracloud.org/coprs/mystro256/gnome-redshift/packages/

## murpholinox

Thanks!!

## Magnus H

Wayland solution worked out of the box, thanks! But I would like to have more general brightness adjustment, not just along this physical color scale. Or at least have a 2-dimensional color and intensity scale.

Many screens have LED backlights with very limited brightness adjust possibilities. One can use dark themes, but that always creates some mess somewhere when you want to use an older application that doesn’t adapt properly or when you do remote desktop/VNC, etc, a generic way of getting it everywhere would be much better.

I have been trying earlier to go through the gnome accessibility settings to adjust brightness on the screen from SW but that did not work for me (bug filed). I suppose you could go through the color profile stuff to hack it in but that’s a bit painful and kind of backwards.

## Steve

Or you could just turn off your devices and leave them in another room (than your bedroom) when going to sleep.

## Hans Anderson

Nice idea of promoting something like Redshift but unfortunately useless. Under a default configuration, it simply wouldn’t work with the most recent Fedora release.

Recommending third-party repositories for Fedora seem not cool either…

## Mystro256

In my defence, I am a fedora dev, but the copr is ultimately a hacky interim solution until someone can come along and properly implement it in GNOME.