-#!/bin/sh
+#!/bin/bash
+cd
+export DISPLAY=:0
+
+case $1 in
+--reset) exec redshift -x ;;
+esac
+
h=$(date +%H)
-if [ ${h#0} -lt 10 -o ${h#0} -ge 21 ]; then
- (pgrep -f /usr/bin/redshift >/dev/null 2>&1 || DISPLAY=:0 exec /usr/bin/redshift -l 42:-71) &
+
+declare -A temps
+temps=(
+ [20]=5000
+ [21]=4500
+ [22]=4000
+ [23]=3500
+ [00]=3000
+ [01]=3000
+ [02]=3000
+ [03]=3000
+ [04]=3000
+ [05]=3000
+ [06]=3500
+ [07]=4000
+ [08]=4500
+ [09]=5000
+)
+
+t=${temps[${h}]}
+if [[ -z ${t} ]]; then
+ exec redshift -x
else
- killall -q redshift
+ exec redshift -O ${t}k
fi
-: