6

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.

  • I don't think that it is possible, but you could enter a fix location instead of using the location provider. – Videonauth Jan 3 '18 at 12:50
  • For the script I'm trying to write, it would be better if you tell which Desktop Environment you are using. Include it in your question and please update "Ubuntu 16" to a valid version (it's either 16.04 or 16.10, even if 16.10 has no more support) – N. Cornet Jan 3 '18 at 14:20
3

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

  1. 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.

  2. Open a new terminal and run

    crontab -e
    

    to edit your cron task table.

  3. 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 and 8-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 change DAY_TEMP and NIGHT_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.
  4. 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...

  • I'm working on a script to have some kind of GUI (and maybe transitions too). Could take some time... – N. Cornet Jan 3 '18 at 14:05
  • 1
    There is a script that already works which you can modify to call Red Shift instead of the kernel to change brightness level as it works now: askubuntu.com/questions/894460/… – WinEunuuchs2Unix Jan 3 '18 at 23:41
  • It seems good and easy enough to adapt to this question. I'm trying to write my own anyway to answer this particular question (and with the ability to pause for some time or disable, as I said), it will not be as good as yours, but will do the work :) – N. Cornet Jan 4 '18 at 9:51
5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.