Thursday, August 1, 2013

AdjustGammaRamp: Adjusting monitor colors for evening and night time viewing for a better sleep

There's a couple programs for Windows that change the colors of the monitor depending of time of the day. Best one for Windows seems to be F.lux and another one is Redshift. Redshift is more directed to Linux distributions but has also a Windows version and decent GUI application, RedshiftGUI.

Both of these programs don't work for me because they are "too easy" to use. They assume user wants the monitor to mimic sun but I live in Finland. The northern part of Finland I was born had only three hour days during the winter. Do I really want my monitor to have the natural D6500 colors for only three hours a day? Same thing in the summer but opposite, only three hours of night. Or none, if you live even farther north.

What I want and need is that I can control when it's time to go to sleep. Dimming the monitor with a red sunset tones an hour before is a good way to improve your sleep.

Both F.lux and Redshift also have a problem that they change to monitor's colors the whole day. There's options in Redshift that you can make it change the colors only in sunset and sunrise but it still tracks the sun. You cannot change the time the colors are changed.

I have a calibrated monitors and I don't want any software to change my calibrations during the day. I also want the calibration to stay even at night viewing but it would just be towards the red tones. And when the day starts, the calibrated D6500 colors should be back.

The software should be able to work with multiple monitors but not necessarily at the same time.

I wrote a little python application that does exactly that. It saves your current gamma ramp and adjusts the new tones at once or with a slow shift. It takes simple parameters as a scale values for Red, Blue and Green colors so if you want to make a red tones, you use parameters 1.0 0.8 0.8 and Green and Blue colors luminance will be 80% of the calibrated colors. When you want to return to day time colors, you just enter parameters 1 1 1 and you are back to accurate calibrated colors.

If you want to run this as python script, it is here:
You have to have a working python environment ( I used 2.7) and the modules the script is using. If you are planning to use this I assume you know what you are doing. The script is not fool proof because you are not a fool.

I also compiled with pyInstaller an executable file that "should work" as is. I haven't tested in other computers but I'm now running this instead of the python script.

Then just add to task scheduler when you want to go into night&daymode. I don't know why, but task window is visible in my computer even it should be hidden so I created a batch file that start's separate process
start "Night/Day Mode" /MIN AdjustGammaRamp.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

Why is there also Save and Restore commands you may ask? I have a scripts I use to change the screen between different monitors so when I change to a new monitor, I also run command AdjustGammaRamp Save automatically that saves the gamma ramp of the new monitor. Each monitor of course has a different gamma ramps because they are calibrated so every time I change the monitor I have to update also the saved gamma ramp. 

Here's two simple commands for changing the modes:
Change to night mode : AdjustGammaRamp Slide 1 1 1 40 1 1 .8 .8
This will change to night mode in 40 steps in a 1 second intervals so the change will last about 40 seconds.
Change back to day mode: AdjustGammaRamp Slide 1 .8 .8 40 1 1 1 1

PS. I hope the police doesn't come knockin' my door for googling 'how to get gamma'...

The files are also in GitHub:

No comments:

Post a Comment