]> git.wh0rd.org - home.git/commitdiff
globalize redshift
authorMike Frysinger <vapier@gentoo.org>
Thu, 7 Aug 2014 04:26:37 +0000 (13:26 +0900)
committerMike Frysinger <vapier@gentoo.org>
Thu, 7 Aug 2014 04:26:37 +0000 (13:26 +0900)
.bin/redshift-check

index a74940625eb7b9a873313b817fd8c52638ace259..c994ad087d0fdd51fd5ef3aa497e98537cb46145 100755 (executable)
@@ -1,8 +1,34 @@
-#!/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
-: