The officially official Devuan Forum!

You are not logged in.

#1 2017-05-23 21:37:37

Capricornus
Member
From: Lombardy, Italy, E.U.
Registered: 2017-05-13
Posts: 14
Website

Redshift: your eyes will thank you.

Long story short:

it adjusts your monitor's color temperature upon day/night time (based on your latitude and longitude) to reduce eyes' stress and insomnia related issues.


What to install and how to configure it:


1) Using synaptic, apt-get, whatever you prefer.

redshift (terminal)
gtk-redshift (XFCE/MATE)
redshift-plasmoid (KDE)


2) create "redshift.conf" into your /home/user/.config directory

copy-paste the template .conf file from the programs' website

http://jonls.dk/redshift/

CTRL+f "configuration file"


3) tune the configuration file:

Each option has plenty of information for fine tuning, I'll point out just the "showstopper" ones:

location-provider=manual // unless you want to use geoclue

[manual]
lat=XX.XX // you can fetch them looking for your city on wikipedia
lon=YY.YY

[randr]
screen=0 // the default is set to "1", which means secondary monitor


4) run it and behold the magic at work

XCFE -> Accessories menu -> Accessories -> Redshift

right clicking on the systray's icon will open a menu


Enjoy some rest for your eyes :)


"It isn't necessary to hope, in order to undertake, nor to succeed to persevere." (Anonymous)

Offline

#2 2017-05-24 02:43:12

zephyr
Member
From: Norman, Oklahoma USA
Registered: 2016-12-01
Posts: 37
Website

Re: Redshift: your eyes will thank you.

^ Going to give this a shot, spend many hours on my PC. This could be the answer to eye fatigue!

Appreciate the post and thank you! : )

Cheers

zephyr

Last edited by zephyr (2017-05-24 02:44:24)

Offline

#3 2017-05-24 04:01:25

smoki
Member
Registered: 2017-05-15
Posts: 56

Re: Redshift: your eyes will thank you.

Capricornus wrote:

1) Using synaptic, apt-get, whatever you prefer.

redshift (terminal)
gtk-redshift (XFCE/MATE)
redshift-plasmoid (KDE)

4) run it and behold the magic at work

XCFE -> Accessories menu -> Accessories -> Redshift

right clicking on the systray's icon will open a menu


Enjoy some rest for your eyes smile

Instead of that 4. step, one can install and run just mentioned terminal variant without pulling whole a lot of gtk3 dependencies, python, etc... big_smile app just wanna glibc and X nothing else.

Basically it is all the same, as once you setup config properly just run commandline variant with a session and that is it.

edit: ah sorry for desinformation, i had minimal expectation but Debian package pull glib/dbus/geoclue on terminal app also, eh... it seems without 500 new packages people can't click on anything these days, newer also ships with systemd service config what kind of madness is all that big_smile Sorry again, speaking to myself mostly.

Last edited by smoki (2017-05-24 04:36:28)

Offline

#4 2017-05-24 18:39:00

GNUser
Member
Registered: 2017-03-16
Posts: 150

Re: Redshift: your eyes will thank you.

Thank you, Capricornus. It works like a charm on my Devuan+MATE laptop. I've been looking for something like this for a while.

I even added "redshift-gtk &" to my list of startup applications so that it automatically kicks in when I boot (yes, the package is called "gtk-redshift" but the command is "redshift-gtk").

EDIT: I found that the redshift notification area icon is a bit glitchy (sometimes its presence interferes with ability of yad notification area icons showing up), so I changed the startup command to simply "redshift &".

Last edited by GNUser (2017-05-25 16:14:27)

Offline

#5 2017-05-25 15:26:08

fsmithred
Administrator
Registered: 2016-11-25
Posts: 471

Re: Redshift: your eyes will thank you.

Maybe the tray works better in the ascii version, which is now called 'redshift-gtk' and works on jessie. I've been using it here all week. I've got a love/hate relationship with it. I love what it does, but I hate when it does it. So I'm not running the tray app. I'm just doing one-shot settings how and when I want. I like clicky, so I made a couple of scripts that use yad. One has a list of preset screen temps and brightness values, the other has dials.

redshifty and redshifty2:
https://gist.github.com/fsmithred/7d072 … 0ba6585327
https://gist.github.com/fsmithred/e8cb0 … f373ab8933

yad is not in jessie. You can get it here:
http://debs.slavino.sk/files-testing.php

Offline

#6 2017-05-26 03:06:23

GNUser
Member
Registered: 2017-03-16
Posts: 150

Re: Redshift: your eyes will thank you.

I wanted manual control over what's considered "daytime" and "nighttime", so I put together this simple script. If you want to use it, simply add the script to your startup applications and make sure redshift is not being automatically started anywhere else (this script takes care of everything).

#!/bin/bash

daytemp=5500
nighttemp=3500
savefile=/tmp/colortemp

while true; do
    daybreak=$(date -d 'today 09:00:00' +%s)
    nightfall=$(date -d 'today 19:00:00' +%s)
    timenow=$(date +%s)
    tempnow=$(cat $savefile)
    if [[ $timenow -gt $daybreak && $timenow -lt $nightfall ]]; then # it's daytime...
        [[ "$tempnow" != "day" ]] && redshift -O $daytemp && echo "day" >$savefile
    else # it's nighttime...
        [[ "$tempnow" != "night" ]] && redshift -O $nighttemp && echo "night" >$savefile
    fi
    sleep 60
done

Note: You don't even need a config file or the gtk-redshift package. "sudo apt-get install redshift" and the script above as a non-root startup job is all you need smile

Last edited by GNUser (2017-05-26 03:12:12)

Offline

#7 2017-05-26 11:50:52

GNUser
Member
Registered: 2017-03-16
Posts: 150

Re: Redshift: your eyes will thank you.

Here's a slightly more elaborate version, in case you want to choose a third color temperature for a transition period between the daytemp and nighttemp. You can change the temperatures and times as you see fit, of course.

#!/bin/bash

daytemp=5500
nighttemp=3500
twilighttemp=4500
savefile=/tmp/colortemp

while true; do
    amtwilight=$(date -d 'today 08:00:00' +%s)
    daybreak=$(date -d 'today 09:00:00' +%s)
    pmtwilight=$(date -d 'today 19:00:00' +%s)
    nightfall=$(date -d 'today 20:00:00' +%s)
    timenow=$(date +%s)
    tempnow=$(cat $savefile)
    if [[ ($timenow -gt $daybreak) && ($timenow -lt $pmtwilight) ]]; then # it's day...
        [[ "$tempnow" != "day" ]] && redshift -O $daytemp && echo "day" >$savefile
    elif [[ ($timenow -lt $amtwilight) || ($timenow -gt $nightfall) ]]; then # it's night...
        [[ "$tempnow" != "night" ]] && redshift -O $nighttemp && echo "night" >$savefile
    else # it's twilight...
        [[ "$tempnow" != "twilight" ]] && redshift -O $twilighttemp && echo "twilight" >$savefile
    fi
    sleep 60
done

Last edited by GNUser (2017-05-26 12:18:21)

Offline

#8 2017-05-26 21:03:49

Max_B
Member
From: Ancona, Marche, Italy
Registered: 2017-04-17
Posts: 15

Re: Redshift: your eyes will thank you.

Devuan ASCII + MATE here, just installed and configured, works like a charm. And it's almost 23.00 here, so upon starting it I noticed immediately the change :-)
Just a question: the cursor now appears a little "blue-ish" to me (is this the right word? I mean it seems not exactly white but with a light shade of blue). Is it normal?

Offline

#9 2017-05-26 21:41:41

Spass
Member
Registered: 2017-05-11
Posts: 21

Re: Redshift: your eyes will thank you.

Max_B, yes it's normal. Cursor appears blueish when you're on low color temperature setting (3500K-4500K) and that probably means your eyes are adapting, so it works as intended :)

From Redshift website:

Redshift won’t affect the color of your mouse cursor when your graphics driver is configured to use hardware cursors. Some graphics drivers have an option to disable hardware cursors in xorg.conf.

Last edited by Spass (2017-05-26 21:49:52)

Offline

#10 2017-06-01 21:20:42

Max_B
Member
From: Ancona, Marche, Italy
Registered: 2017-04-17
Posts: 15

Re: Redshift: your eyes will thank you.

Yes, it works, now started from .xinitrc. smile More, when I launched it first time from terminal to test the configuration (I entered my local coordinates), the change was drastic within seconds because as I said it was night. When I did ctrl-c the screen returned immediately to its "native" state, and I have to say my eyes almost hurted for some seconds.

As for the cursor as I said it was just my curiosity, it's not a problem smile

Offline

#11 2017-06-07 12:35:58

linijkarz
Member
Registered: 2017-06-04
Posts: 12

Re: Redshift: your eyes will thank you.

Your eyes will thank you but your memory won't.

Redshift is frankly unbelievably bloated for a tool that does so little. There's a better alternative - sct

Contained within 40 lines of C that you can easily integrate with a simple and minimal desktop like OpenBox.
With some script and cron magic you can achieve exactly the same result at 1% the resource expense.
Isn't it what this distribution is all about? big_smile

/* public domain, do as you wish */
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xrandr.h>

#include <stdlib.h>
#include <math.h>


/* cribbed from redshift, but truncated with 500K steps */
static const struct { float r; float g; float b; } whitepoints[] = {
	{ 1.00000000,  0.18172716,  0.00000000, }, /* 1000K */
	{ 1.00000000,  0.42322816,  0.00000000, },
	{ 1.00000000,  0.54360078,  0.08679949, },
	{ 1.00000000,  0.64373109,  0.28819679, },
	{ 1.00000000,  0.71976951,  0.42860152, },
	{ 1.00000000,  0.77987699,  0.54642268, },
	{ 1.00000000,  0.82854786,  0.64816570, },
	{ 1.00000000,  0.86860704,  0.73688797, },
	{ 1.00000000,  0.90198230,  0.81465502, },
	{ 1.00000000,  0.93853986,  0.88130458, },
	{ 1.00000000,  0.97107439,  0.94305985, },
	{ 1.00000000,  1.00000000,  1.00000000, }, /* 6500K */
	{ 0.95160805,  0.96983355,  1.00000000, },
	{ 0.91194747,  0.94470005,  1.00000000, },
	{ 0.87906581,  0.92357340,  1.00000000, },
	{ 0.85139976,  0.90559011,  1.00000000, },
	{ 0.82782969,  0.89011714,  1.00000000, },
	{ 0.80753191,  0.87667891,  1.00000000, },
	{ 0.78988728,  0.86491137,  1.00000000, }, /* 10000K */
	{ 0.77442176,  0.85453121,  1.00000000, },
};

int
main(int argc, char **argv)
{
	Display *dpy = XOpenDisplay(NULL);
	int screen = DefaultScreen(dpy);
	Window root = RootWindow(dpy, screen);

	XRRScreenResources *res = XRRGetScreenResourcesCurrent(dpy, root);

	int temp = 6500;
	if (argc > 1)
		temp = atoi(argv[1]);
	if (temp < 1000 || temp > 10000)
		temp = 6500;

	temp -= 1000;
	double ratio = temp % 500 / 500.0;
#define AVG(c) whitepoints[temp / 500].c * (1 - ratio) + whitepoints[temp / 500 + 1].c * ratio
	double gammar = AVG(r);
	double gammag = AVG(g);
	double gammab = AVG(b);

	int num_crtcs = res->ncrtc;
	for (int c = 0; c < res->ncrtc; c++) {
		int crtcxid = res->crtcs[c];
		XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(dpy, res, crtcxid);

		int size = XRRGetCrtcGammaSize(dpy, crtcxid);

		XRRCrtcGamma *crtc_gamma = XRRAllocGamma(size);

		for (int i = 0; i < size; i++) {
			double g = 65535.0 * i / size;
			crtc_gamma->red[i] = g * gammar;
			crtc_gamma->green[i] = g * gammag;
			crtc_gamma->blue[i] = g * gammab;
		}
		XRRSetCrtcGamma(dpy, crtcxid, crtc_gamma);

		XFree(crtc_gamma);
	}
}
cc -std=c99 -O2 -I /usr/X11R6/include -o sct sct.c -L /usr/X11R6/lib -lm -lX11 -lXrandr

Usage is simple, sct followed by desired color temperature in kelvin.

All due respects to the author :
http://www.tedunangst.com/flak/post/sct … emperature

Offline

#12 2017-06-07 13:33:55

GNUser
Member
Registered: 2017-03-16
Posts: 150

Re: Redshift: your eyes will thank you.

linijkarz wrote:

you can achieve exactly the same result at 1% the resource expense.
Isn't it what this distribution is all about? big_smile

Indeed smile

Thank you very much for this. I compiled it and it works as advertised. Minimalism is a beautiful thing.

Offline

#13 2017-06-07 16:22:15

Somewhat Reticent
Member
Registered: 2017-04-06
Posts: 100

Re: Redshift: your eyes will thank you.

Wouldn't it be nice to 'go manual', with "sliders" - one for color_temperature, one for brightness, instead of buttons on a display?
That could separate timer (and optional geolocation?) as a cron control layer, right?
:::
(btw, I respect the work that a BDFL put into f.lux; it copes with a wide range of hardware idiosyncracies, and the gradual fade is gentler.)

Last edited by Somewhat Reticent (2017-06-27 17:54:13)

Offline

#14 2017-06-27 17:55:53

Somewhat Reticent
Member
Registered: 2017-04-06
Posts: 100

Re: Redshift: your eyes will thank you.

Or  (more minimally) is there a way to include parameters (increments of time and color-temp) for gradual fading between dark-shift and bright-shift?
And what about a similar control for brightness?

Offline

#15 2017-06-27 23:36:49

fsmithred
Administrator
Registered: 2016-11-25
Posts: 471

Re: Redshift: your eyes will thank you.

redshifty (first script I linked in my post above) looks like this. Not exactly sliders, but you can dial in the numbers you want. And you can change the upper and lower limits by editing the script. I just picked what I thought were sane limits.
redshifty

I've thought about making one that changed the settings gradually over time. If I ever get around to it, it will probably go through a few settings over 10 or 20 minutes, starting from wherever it is to some percentage darker and redder (or brighter and bluer).

I tried sct, but it only worked on one monitor. Is there a trick to get it to change both monitors?

Offline

#16 2017-08-17 16:37:01

pepa65
Member
Registered: 2017-07-06
Posts: 4

Re: Redshift: your eyes will thank you.

This way sct will work on all screens:

https://github.com/pepa65/misc/blob/master/sct.c

Offline

#17 2017-09-05 01:10:27

zapper
Member
Registered: 2017-05-29
Posts: 56

Re: Redshift: your eyes will thank you.

Redshift has been buggy for me in the past, but I am currently using it now. smile thanks.

Offline

Board footer