Redshift configuration - how to set fixed transition hours?
Is it possible to configure Redshift so that screen color changes at fixed hours regardless of actual Sun position? I'm using Redshift 1.10-5ubuntu1 on Ubuntu 16.04 and GNOME.
Solution 1:
Redshift does provide custom fixed transition times in the redshift config file in ~/.config/redshift.conf
To set these times, add the fields dawn-time
and dusk-time
and add a time to set the time periods. My configuration file looks like this for example:
[redshift]
dawn-time=04:00-05:30
dusk-time=21:00
According to this pull request:
These option can specify an interval like 04:00-05:30 or an instant 18:00 which is equivalent to 18:00-18:00. The transition between day and night color temperature takes place in the specified interval. Currently times must be specified in 24-hour format and the beginning of dawn must be after midnight and the end of dusk must be before midnight. When time-based adjustment is specified, no location provider is needed and it will therefore not be initialized and used.
Solution 2:
Redshift doesn't provide an option to set day and night time.
What I did was set up a cron task to set the colour temperature every x minutes, according to the hour.
The command I use :
redshift -O TEMPERATURE
set the temperature at TEMPERATURE
only once (Redshift won't run in background to compute if it as to change the temperature all the time).
How to set the cron task
-
If you don't know how to use Vim (if you do you can jump this step), open a terminal (Ctrl+Alt+T) and change the default editor by running
echo "export EDITOR=nano" >> ~/.bashrc
Now close your terminal to apply.
-
Open a new terminal and run
crontab -e
to edit your cron task table.
-
Go to the end of the file and add this lines:
*/5 17-7 * * * DISPLAY=:0 redshift -O NIGHT_TEMP >> /home/USER/cron.log 2>&1 */5 8-16 * * * DISPLAY=:0 redshift -O DAY_TEMP >> /home/USER/cron.log 2>&1
-
*/5
is the interval in minutes (every minute that can be divided by 5) -
17-7
and8-16
are the hour range (every hour between 5 p.m. and 7 a.m. for the night, and between 8 a.m. and 4 p.m. for the day) -
* * *
is the date (so every day [of the month], every month, and every day of the week).
So, in my example, the first command (for night time) is executed every 5 minutes (0, 5, ..., 55) between 17:00 and 7:59 everyday, and the second command (for day time) every 5 minutes between 8:00 and 16:59.
The commands that follow are what is executed at the (previously) specified time :
-
DISPLAY=:0
is for running the command on a display (otherwise it is on background, which is useless in our case). Don't change it unless you are using an external monitor, most of the time the default display port is:0
. -
redshift -O TEMPERATURE
is the command we saw above, of course changeDAY_TEMP
andNIGHT_TEMP
to the temperatures you want for the day and for the night. -
>> /home/USER/cron.log 2>&1
redirects the (error) messages to/home/USER/cron.log
(that can be useful if your display is NOT on:0
). Change/home/USER
to your home directory.
-
Exit your editor : if you did step 1., press Ctrl+X then Y and finally Enter.
Don't forget to remove Redshift from Startup Applications.
Now you are done.
Some side effects are : you won't have a GUI to suspend Redshift or to disable it ; there will be no transitions (it will change directly from DAY_TEMP
to NIGHT_TEMP
) and that can be surprising if not unpleasant...