Fighting bad sleep with Redshift

There is a lot of fuss nowadays about how modern human behaviour influences our sleep pattern in a bad way. We watch TV in bed, use our smartphone or tablet before we go to sleep. Not everyone is affected in the same way - some people still sleep well, others turn into bad sleepers.

Of course, the best way would be to do away with the bad habits, but since we're probably not doing that anytime soon, say hello to the runner-up: mitigation. But first, a bit of background. Natural light shifts during the day - everyone has seen the red/orange hue that's part of a beautiful sunset, for example. Or the cold winter sun, even at its highest. During the day, the light is more blue-ish. Since it evolves gradually, it's barely perceivable to the human eye, but the blue light keeps us awake (and blocks melatonin production, which is said to be important for good sleep).

Light can be perceived as warm, or cold. The light a TL light or a cheap LED bulb emits is often felt as harsh, cold light, whereas the classic lightbulb often has a warmer hue. That's what science classifies as 'colour temperature'. It's indicated in Kelvin (K), and LED bulbs often come with statements like '2700K' or '3000 Kelvin' to indicate what kind of light they'll radiate. A traditional light bulb e.g. is usually around 2700K, which humans perceive as warm light. Full daylight, though, is around 5000K. Computer screens are more or less designed to mimic that. Funny thing: the 'warmer' light is perceived, the lower its temperature in Kelvin will be.

So, with that in mind, and the knowledge that the blue part of the light spectrum might keep us awake - when natural light has long changed, but we keep staring at our big or tiny screens - some bright minds have devised a solution to adapt our screens to the late hours. Tools like f.lux or the (aptly named) redshift will adjust the colour levels of your display depending on the time of the day, and your geographical position.

F.lux requires you to agree to a EULA, and there's talk of patents on their website, so with the FOSS philosophy in mind I have turned to redshift. Now, on Debian Jessie, it will pull in the libgeoclue0 library, but that didn't work too well:

$ redshift 
Trying location provider `geoclue'...
Unable to obtain master client: The name org.freedesktop.Geoclue.Master was not provided by any .service files
Failed to start provider geoclue.
Trying next provider...
Trying location provider `manual'...
Latitude and longitude must be set.

Now I should probably fix that, but I've never been a hero with anything D-Bus, so I'd rather set my coordinates manually and tinker some. You can grab the GTK frontend - gtk-redshift but that didn't work too well for me on Gnome 3 (probably PICNIC as well, but hey). I set it up without.


First, grab your coordinates from a site like Then create the config file (you can copy the default configuration from the author's website):

$ vim ~/.config/redshift.conf

Now, set your coordinates, with up to two decimals:



You can also set colour temperature (either in general or for day and night). Play around a bit with the values to see what fits you. By default, redshift will apply a smooth transition so it takes a bit to notice the difference. I am using the following values:


You can set brightness as well, but as the author notes himself, this doesn't actually dim the backlight; it adjusts the gamma values. That's why I have commented those values completely; if you would like to adjust your backlight according to the time of day I'd recommend you write a little cronjob or just do it manually (especially on a laptop it's pretty trivial nowadays).


I have tried to create a desktop file in ~/.config/autostart/, but nothing worked well with Gnome 3. In the end I created the traditional ~/.xprofile file, which gets picked upon login:

cat ~/.xprofile
# .xprofile
/usr/bin/redshift &

Easy, and what's most important: it just works ™. I hope you find it useful - my eyes certainly do :).