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.86k stars 424 forks source link

You shouldn't be able to open Redshift again. #446

Closed ghost closed 7 years ago

ghost commented 7 years ago

System : Solus with budgie desktop latest.

Problem : The user is able to open multiple Redshift processes.

Problems that this issue generates :

~Suggested Solution : If the user opens Redshift again, Redshift should restart the current process.~ Edit:

Suggested Solution :

If the user opens Redshift again, Redshift should ask the user to open another process or restart the current process or just ignore the event and act as nothing happened

maandree commented 7 years ago

I completely disagree. You may have one Redshift process open monitor and display, and if you use https://github.com/jonls/redshift/pull/410 there is not problem with having multiple instances running and affecting the same monitor, although I don't think there is a logical reason you would want to do this. Redshift must keep track which process is affecting which monitor and display (and other possible weird things the user may want to do) if it should be able to restart a running process without any undesirable side-effects.

However, if you really want this I suggest adding a signal to Redshift that this (it is needed anyway, although it shouldn't do a full restart, but instead only fetch to new location and transition to updated configurations) and leave it up to the user to add the wrapper (I haven't checked that this script is correctly written)

if pgrep -x redshift >/dev/null; then
    exec pkill -x -USR2 redshift ## assuming the added signal is SIGUSR2
else
    exec redshift
fi
jonls commented 7 years ago

As @maandree explained, this is currently not something we can implement. Multiple instances of Redshift are currently needed for certain configurations so we are not at a point where we can disallow multiple instances.

ZettaScript commented 1 year ago

There could be an option in the config file to disallow multiple instances. Precisely, an instance with this option enabled will exit immediately if there was already another redshift process running.

This would solve a bunch of open issues about flickering due to multiple instances.

I will try to make a PR if I have time.