jonls / redshift

Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night.
http://jonls.dk/redshift
GNU General Public License v3.0
5.9k stars 428 forks source link

Enabling monitor requires loading its gamma ramps, but Redshift resets them #759

Open dreamlayers opened 4 years ago

dreamlayers commented 4 years ago

Is your feature request related to a problem? Please describe. Redshift uses display gamma ramps which were present when it was started. When a monitor is disabled, xcalib can't load gamma ramps for that output. So, if I enable a monitor for the first time in an X session, I need to kill Redshift, load the monitor's profile, and start Redshift again. If I don't restart Redshift, it will keep reapplying the old gamma ramp, making it impossible to keep the desired gamma ramp for the newly connected monitor.

Describe the solution you'd like I would like to be able to simply turn on my second monitor and have it use the proper gamma ramp, without the need for workarounds. I'm not sure what's the best solution. Maybe Allow ICC profile as parameter #309? Ideally I think Redshift should preserve any gamma ramps which are loaded by other applications. I guess that would require periodically reading gamma ramps before applying them. Such changes would be a flash to blue if Redshift is active, but that's better than resetting the ramp and requiring restarting of Redshift to make changes stick.

Describe alternatives you've considered Another possibility is to start X with both monitors enabled, load their gamma ramps, start Redshift, and disable the second monitor. Then when it gets re-enabled it will have the proper gamma ramp.

Additional context The gamma ramp preserve function is nice, allowing me to both have a calibrated monitor and blue light reduction when I want it. But it's annoying when I want to make changes because they keep getting reset

jonls commented 4 years ago

I definitely see the issue. I would like to avoid having to handle ICC profiles explicitly in Redshift since it adds additional dependencies and maintenance burden for something that is not going to be useful to the majority of users.

I'm not sure if it would be feasible to check if some other program has modified the gamma ramp. We could of course save the last gamma ramp written by Redshift and compare it (which adds some additional complexity) but there would be race conditions with that approach since we cannot lock the gamma ramp or otherwise detect if they have been modified in a single operation. I'm not sure if there's a way to work around that.

Another option that I've considered is that sending SIGUSR1 to pause Redshift would restore the original gamma ramps and then when you send SIGUSR1 again Redshift would try to rediscover screens and reload the existing gamma ramps at that time. With this I think you could just pause Redshift, load the profile, then unpause and it should work. I'm not sure if that would really be more convenient to you?