fruitcombo

go back

cycling screen color tempurature throughout the day with sct and cron

sct is a great program but unfortunately has no built in automation function, so i made one.

first, make sure you have sct and cron installed. cron is preinstalled on many linux distros, you can check if it's running with service cron status, which should return active among other details. on linux mint, you can install sct with sudo apt install sct.

next, create a file for the script. you can put it wherever you want, such as ~/.local/bin or ~/Applications. you can download this example by clicking here. 6500 is the default screen color tempurature.

#! /bin/bash
  # tell cron where to output visual
export DISPLAY=:0
  # get current hour
time=$(date +%H)
  # set tempurature per hour
if [ $time = 00 ] # midnight
  then
    /usr/bin/sct 3000
  fi
if [ $time = 01 ] # 1 am
  then
    /usr/bin/sct 3000
  fi
if [ $time = 02 ] # 2 am
  then
    /usr/bin/sct 3000
  fi
if [ $time = 03 ] # 3 am
  then
    /usr/bin/sct 3000
  fi
if [ $time = 04 ] # 4 am
  then
    /usr/bin/sct 3500
  fi
if [ $time = 05 ] # 5 am
  then
    /usr/bin/sct 3500
  fi
if [ $time = 06 ] # 6 am
  then
    /usr/bin/sct 4000
  fi
if [ $time = 07 ] # 7 am
  then
    /usr/bin/sct 4500
  fi
if [ $time = 08 ] # 8 am
  then
    /usr/bin/sct 5000
  fi
if [ $time = 09 ] # 9 am
  then
    /usr/bin/sct 5500
  fi
if [ $time = 10 ] # 10 am
  then
    /usr/bin/sct 6000
  fi
if [ $time = 11 ] # 11 am
  then
    /usr/bin/sct 6000
  fi
if [ $time = 12 ] # noon
  then
    /usr/bin/sct 6500
  fi
if [ $time = 13 ] # 1 pm
  then
    /usr/bin/sct 6500
  fi
if [ $time = 14 ] # 2 pm
  then
    /usr/bin/sct 6500
  fi
if [ $time = 15 ] # 3 pm
  then
    /usr/bin/sct 6500
  fi
if [ $time = 16 ] # 4 pm
  then
    /usr/bin/sct 6000
  fi
if [ $time = 17 ] # 5 pm
  then
    /usr/bin/sct 6000
  fi
if [ $time = 18 ] # 6 pm
  then
    /usr/bin/sct 5500
  fi
if [ $time = 19 ] # 7 pm
  then
    /usr/bin/sct 5000
  fi
if [ $time = 20 ] # 8 pm
  then
    /usr/bin/sct 4500
  fi
if [ $time = 21 ] # 9 pm
  then
    /usr/bin/sct 4000
  fi
if [ $time = 22 ] # 10 pm
  then
    /usr/bin/sct 3500
  fi
if [ $time = 23 ] # 11 pm
  then
    /usr/bin/sct 3500
  fi

jumping from one setting to another can be jarring, so you could add transition animations with something like this. (i haven't as i haven't decided if i'm completely happy with this schedule yet)

if [ $time = 04 ] # 4 am
  then
   /usr/bin/sct 3100 # starting from 3000 the previous hour
   sleep 0.5
   /usr/bin/sct 3200
   sleep 0.5
   /usr/bin/sct 3300
   sleep 0.5
   /usr/bin/sct 3400
   sleep 0.5
    /usr/bin/sct 3500
fi

to have this script be executed hourly, add it to your user's crontab file. to edit it, enter:

crontab -e

add this text that tells cron to run it at the first minute of every hour, then save the file:

0 * * * * /full/path/to/sct-schedule

it may also be wise to have an xfce panel launcher with this script in case you start using your computer away from the top of the hour, and with different sct tempuratures for greater control.