Protect Your Eyes From Strain With Redshift in Linux

Protect Your Eyes From Strain With Redshift

Did you ever have problems falling asleep after staying up late with a computer or smartphone? Most computer screens emit a blueish light by default to imitate daylight so that they appear more natural to look at. While it probably has an aesthetic advantage, it also has an unwanted side-effect.

Your sleep cycles are regulated by a hormone called melatonin which is secreted into your system in the absence of daylight. As soon as you see the sun (or rather the blue sky) in the morning, the production of the hormone stops until it gets dark again. Think about it like nature’s own sleeping draught built right into your system. Unfortunately the blue light of the screen blocks melatonin production, keeping you awake long after you have turned your screen off.

The solution would be to have the screen’s colours adjusted so there is less blue in it. Redshift is a simple tool that is capable of just that: It automatically adjusts the screen’s colour temperature according to your location and the time of day. It works much like f.lux on Windows or Mac. Redshift was in fact inspired by f.lux and is available free of charge for anyone wishing to use it.

Installing redshift on your system

Most major Linux distributions have packages built for easy installation. You would usually have two packages, “redshift” and “redshift-gtk.” The former is the basic package while the latter includes a system-tray indicator icon. To install both on a Debian-based system is as simple as  looking it up in the built-in software centre of your OS or typing

into a terminal.

Finding the right colour temperature

Before configuring redshift you should play around with the colour temperature settings until you find the one most suitable, unless you want to end up with a screen looking like you have a video cable problem. To achieve this, you can use the “one shot” option, with the -O switch.

For example, typing

will set the screen colour temperature to 3500K (that is °Kelvin). (The neutral screen colour is 6500K; anything lower than that will turn your screen towards a more reddish hue.)

Redshift addjusted colour.

To reset to neutral, you can use the -x switch:

Of course 3500K is quite extreme. Play around with colour temperatures until you find a setting that still feels natural. It helps to have a few applications open, preferably those that have a light background, as these will show the greatest difference.

You would need to find the right settings for both daytime and night-time hours. The default values for redshift are 5500K/3500K respectively. Chances are that you will find the default daytime colour still “too red” as it is 1000K below “neutral.” If you do not want to change your usual display setting for the daytime, you can stick with 6500K and just find the ideal “redness” for the night.

To set both daytime and night-time temperatures, you can use the -t switch:

The setting

would produce a less “forceful” colour change:

A more natural colour adjustment.

Adjusting screen brightness

You could also dim/brighten your screen with gamma values between 0.1 and 1.0, using the -b switch, like

If for example, you would like to dim your screen for the night to 60% brightness, while having it on full blast during the day, you could achieve this with

which would considerably darken your screen for the night, as you can see below.

Redshift addjusted brightness.

Determining geographical location

Once you have found the right colour and brightness settings, you will need some geographical data to auto-adjust to the daylight hours. Redshift can use your system’s built-in geo-location provider, so you will not need to worry about latitude and longitude details.

will tell you what providers are available on your system.

Redshift showing available geolocation providers.

You can see above that geoclue is installed. Using it is easy:

If you do not have a location provider installed or you prefer not to use it, you can always set your latitude and longitude manually in the format of

If you don’t know your exact coordinates, you can use the Find Latitue and Longitude website to figure them out in seconds. If you are in Paris (France) for example, your coordinates would be:

Other options

Rredshift has some more advanced configuration options as well. To find out all its capabilities, use the -h switch:

Redshift help.

The full command

Now you know your desired screen colour temperature, brightness and your location. Assuming you are still in Paris, you want to have your night-time screen temperature at 5000K with the daytime setting unchanged, having full brightness during the day and 80% brightness at night, so you would type:

Or to automatically detect location:

The results are somewhat more friendly:

A more natural colour adjustment.

Tray indicator

If you also wanted to have a tray indicator icon when Redshift is running, that will allow you to enable/disable Redshift temporarily or permanently, you can use “gtk-redshift”:

Redshift tray icon.

You can always check the status of Redshift by right-clicking this indicator and selecting “Info”:

Redshift info window.

Starting Redshift automatically

To have it start automatically with your system, you would add the above command to your startup applications. On a Ubuntu-based system this would be as easy as typing “startup applications” into the dash (Unity) or the activities overview (Gnome shell) search …

Adding startup application.

… select Add …

Ubuntu startup applications dialogue.

… and paste your Redshift command.

Paste the command to start Redshift.

This would have Redshift start every time you boot your system and would adjust the screen according to your preferences.

Conclusion

Redshift is a great tool to prevent eye strain and insomnia. Of course, first you will need to get used to the slightly reddish hue of your screen at night, but that would come naturally after a few days of active use.

Good night!

20 comments

  1. I got it installed in Mint 17, but no matter what I did it kept locating me about 1,000 km. south of where I am, and that just won’t work at all. There’s very little sunset down there. And I do live within the latitude of where it’s supposed to work. I had to uninstall it again. I used to use f.lux in Windows so I know it’s a good program.

    1. That sounds like your location provider needs configuring. Geolcue tries to get your location from your IP address and is of course not guaranteed to work.

      You can try redshift -l list to see if you have an alternative choice on your system, or enter your latitude and longitude data manually (see in post how).

      1. I decided that if I wanted it done right I’d enter the latitude and longitude myself. I used Wikipedia and Google Maps for sources – they were different, but barely. And it made no difference. I followed the directions given in your article and even checked the Redshift page. It just wouldn’t take, even on repeated tries and after rebooting or logging off and back on.

        1. What exactly was the error after entering latitude and longitude manually? Does it still assume the wrong coordinates?

          Could you try the following:

          1. Clear the autostart command from the system autostart apps

          2. Towards the evening, enter the startup command:

          gtk-redshift -l LATITUDE:LONGITUDE -t 6500:2000

          to a terminal and leave the terminal running.

          Note down any error messages it may give in the terminal window. After it starts (if it starts), please check the system tray icon and check the “status” message and if the coordinates there are right.

          It’s best to use a very low number for testing, as redshift will change the screen colour gradually. You will not notice a sudden colour shift, it should happen over the course of ~10-30 minutes, during which it will read “transitioning” on the info window and slowly but constantly lower the colour temperature. the effect is such, that you might not even notice the screen’s colour has changed, at least not consciously.

          If the above does not help, please post the output of the above command here, or contact me privately and I will try to help and resolve this for you.

          1. Thanks for taking the time to help. It may take some time for me to be home at that time of day, but I have this page bookmarked and I’ll give it a try and post back to let you know what happens, good or bad.

  2. Going to try this on Linux Mint 17.1 with Cinnamon and Ubuntu 14.04 with XFCE.

    1. Great, let us know how it went, will you?

  3. This time it worked fine. I opened Terminal and used the startup command about 1815, 3 hours before sunset, and I started to notice a difference about half an hour before sunset. Terminal wasn’t showing any errors, and the lat/long was correct. I’m happy with 6500K for daytime, but would like to limit night to about 4500K for now. That looks a bit dark with no room lights, but lighter after the room lights are turned on, so I think that would be a good starting point. So would I use the following in the Startup Applications Preferences:
    Name: autostart-redshift
    Command: gtk-redshift -l latitude:longitude -t 6500:4500 -b 1.0:0.7
    and use the same command in Terminal, or would using it in Startup Apps be enough? I’m using Mint 17 64-bit.

    1. I’m glad it had worked finally. The above command is correct, it should set your screen at 4500K and 70% brightness for the night. If you find it looks dark, you can give it 0.8 or 0.9 instead of 0.7, just experiment how it’s best.

      You would only need to set it up the Startup Application Preferences once, and then you can just forget about it. It will start with your system and adjust itself automatically. You need not use the terminal, it was only necessary for troubleshooting.

      1. I started Redshift this morning after reading your post so I could get the lat/long easily from Info in the icon, and noticed that the color was already a bit red. The lat/long is wrong again, back to what it was, and the color is 5500K. Do I still continue with setting up the Startup Application Preference or do I have to do something more?

        1. I think, if it works with the auto-start prefs, you should go on with that. Just paste the command you have written in your previous comment:

          gtk-redshift -l latitude:longitude -t 6500:4500 -b 1.0:0.7

          and it should work.

          Only out of curiosity, what command did you use when you started redshift last time?

  4. I had more time to play with it tonight and tried the setting in Startup App. Pref. and it all worked well. The location is correct, and I’ve played with the temperature setting a bit. I have it on 4800K right now and it looks about right.
    I do have a question, though. Is the -t setting and the -b setting the same thing? Could I use one or the other rather than both? And if I use both but the -t ratio is different than the -b ratio, (e.g. 6500:5000 and 1.0:0.5) what happens?
    Thanks for posting this and more thanks for helping me set it up.

    1. They are not the sam,e although similar: --t will set the colour temperature (i.e. more red or more blue), while -b will set the brightness in precents, e.g. 0.7 means 70% brightness, etc.

      When you set --t, you do what redshift is supposed to do, turn the screen more red. E.g.
      -t 6500:4800 will leave your screen “neutral” for the day, while turning it down to 4800K for the night.

      The -b switch is useful, when you find our screen too bright in the evening:
      -b 1.0:0.5 will leave the brightness on 100% for the day and turn it down to 50% for the night.

      Both switches can be used together or one-by-one, it is up to your preference. Hope this helps. :)

    2. Sorry, I made a mess in the other comment and cannot edit it. It is meant to be -t, not --t (no double dash needed)

      1. Ok, thanks for that, it helps a lot. I have it set at 4800K and 0.8 now, and although it seemed a bit weird at first I didn’t really notice it after about 15 minutes of use. Can I adjust the -b value by less than .1 to fine-tune it, like 0.8 to 0.75, or does it only work in .1 increments/decrements? Are there -t and -b values that would be considered threshold values, so settings closer to 6500K and 1.0 than that wouldn’t be beneficial for aiding sleep?

        1. I’m not sure about the increments, for my eyes there appears to be a difference when I try it, but it might just be placebo. it is best to experiment and find you preferred settings.

          Yes, it takes some getting used to, for me it took much more than 15 minutes for the first time, but now I could not live (and work) without it. I’m not sure there would be threshold values, as this will all come down to your personal preferences and even your screen quality and tuning.

          the bottom line is, the redder the better, so theoretically even a slight adjustment would be marginally beneficial, but to see any real results, it is considered best to make more “drastic” changes. I have noticed on my screen (Acer G245HQ) that setting -t 5000K and -b to 0.9 already helps. On yours it can be different, but 4800K sounds like you will see some benefits already.

  5. I have Linux Mint 17.2 “Rafaela” MATE 64-bit and the Redshift tool work perfect with one exception: the brightness stay unchange to value 1.000:1.000. I put ‘brightness=1.0:0.9’ in redshift.conf, I put the ‘-b 1.0:0.9’ in “Startup Applications” where I edit command for “Redshift”, I put the same, ‘-b 1.0:0.9’, in Redshift Luncher Properties when I edit command…In vain! “redshift -v” invariably returned: “brightness=1.000:1:000”!
    Command: gtk-redshift -l 42.20:4.53 -t 6500:5000 -b 1.0:0.9 -g 0.9:0.8:0.9
    Any ideas? Thank you!

    1. Hi,

      redshift and gtk-redshift are two separate executeables. They do the same thing, but gtk-redshift also includes a system tray indicator. So when you set up your command like

      gtk-redshift -l 42.20:4.53 -t 6500:5000 -b 1.0:0.9 -g 0.9:0.8:0.9

      you are running gtk-redshift, which should behave as expected, while

      redshift -v

      will show you the output of “plain” redshift, which did not the the brightness argument.

      What I suggest is that you use either of the two consistently. If your launcher is set to gtk-redshift, the easiest way to check if it’s correct is to hover/click on the system-tray icon, while it’s active (that is at night), and see what it says.

      Additionally, your launcher command is correct (I use the same settings), but if you want to use redshift.conf, you can either set brightness globally (for all situations, night and day) with brightness=0.9, but if you want different settings you must use:

      brightness-day=1.0
      brightness-night=0.9

      This will make both commands redshift and gtk-redshift run with the correct settings, without having to put command line arguments in the launcher itself.

      I hope this helps. :)

  6. Is there a program like this that doesn’t require anything involving geolocation?

    1. Not that I’m aware of. Anyway, it would not work very well, as your geographical coordinates will be the best shot at determining sunset/sunrise times. Sure you could adjust these manually, but to be accurate, you would probably end up doing it every week or so. Unless you live on the equator. In which case, it’s still bad news, there does not seem to be any.

Comments are closed.