]> git.wh0rd.org - home.git/blob - .bin/redshift-check
redshift: clean up a bit
[home.git] / .bin / redshift-check
1 #!/bin/bash
2
3 usage() {
4 cat <<-EOF
5 Usage: ${0##*/} [options]
6
7 Options:
8 --reset reset display to no redshift
9 EOF
10
11 if [[ $# -eq 0 ]] ; then
12 exit 0
13 else
14 printf '\nERROR: %s\n' "$*" >&2
15 exit 1
16 fi
17 }
18
19 main() {
20 cd
21 export DISPLAY=:0
22
23 while [[ $# -gt 0 ]] ; do
24 case $1 in
25 --reset) exec redshift -x ;;
26 -h|--help) usage ;;
27 *) usage "Unknown option: $1" ;;
28 esac
29 done
30
31 h=$(date +%H)
32
33 declare -A temps
34 temps=(
35 [20]=5000
36 [21]=4500
37 [22]=4000
38 [23]=3500
39 [00]=3000
40 [01]=3000
41 [02]=3000
42 [03]=3000
43 [04]=3000
44 [05]=3000
45 [06]=3500
46 [07]=4000
47 [08]=4500
48 [09]=5000
49 )
50
51 t=${temps[${h}]}
52 if [[ -z ${t} ]]; then
53 exec redshift -x
54 else
55 exec redshift -O ${t}k
56 fi
57 }
58 main "$@"