Redshift Delayed Dimming Hack
Redshift automatically winds down the color of my display as day turns to night. I don’t know if it helps me sleep as the experts say it will, but it cuts down on eye strain significantly. I only have one gripe: my display gets really red really early in the evening. That’s not even a fault of the application. My schedule and the sun share equal blame in the premature dimming of my screen.
I choose to toggle Redshift off if I’m editing images or styles since colors matter for those tasks, but I often forget to toggle it on once I’m done. I wanted a way to make sure that Redshift was enabled an hour before I go to bed on most nights so that I’d know to wind down.
D-Bus provides a great conduit for that sort of runtime inter-process communication and configuration, but Redshift doesn’t yet come with a D-Bus interface.
Three factors join forces that allow me to schedule Redshift display dimming in a less ideal way:
-
Redshift listens for
USR1
signals and toggles dimming on receipt. -
xrandr
displays current gamma information (and Redshift dims the display by altering the gamma) -
Cron scripts run by my user account have access to my XAuthority credentials.
In an ideal world I’d add D-Bus support to Redshift for a more elegant solution and a fun bit of C programming. It’s on my “someday maybe” list for a time when I can afford to fumble with a language I last used around 2004. In the meantime, this inelegant shell script does the job and gets me back to work on more pressing projects. Maybe it’ll work for you, too.