-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetredshift
More file actions
executable file
·75 lines (65 loc) · 2.07 KB
/
setredshift
File metadata and controls
executable file
·75 lines (65 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
DIRNAME="$(dirname "$0")/.tmp"
mkdir -p "$DIRNAME"
if [ ! -e "$DIRNAME/cur_brightness" ]; then
echo 1 > "$DIRNAME/cur_brightness"
fi
if [ ! -e "$DIRNAME/cur_temp" ]; then
echo 6500 > "$DIRNAME/cur_temp"
fi
curbrightness=$(cat $DIRNAME/cur_brightness)
curtemp=$(cat $DIRNAME/cur_temp)
if [[ ("$1" == "--reset") ]]; then
redshift -x
echo 1 > $DIRNAME/cur_brightness
echo 6500 > $DIRNAME/cur_temp
exit 0
fi
while getopts ":b:t:" opt; do
case $opt in
b) arg_1="$OPTARG"
INCR=0.1
if [[ ("$1" == "-bi") ]]; then
new=$(echo "$curbrightness+$INCR" | bc)
valid=$(echo "$new >= 0 && $new <= 1" | bc)
echo $new
elif [[ ("$1" == "-bd") ]]; then
new=$(echo "$curbrightness-$INCR" | bc)
valid=$(echo "$new >= 0 && $new <= 1" | bc)
elif [[ ("$1" == "-br") ]]; then
new=1
valid=1
fi
if [[ $valid -eq 1 ]]; then
redshift -P -O $curtemp -b $new
echo $new > $DIRNAME/cur_brightness
fi
;;
t) p_out="$OPTARG"
INCR=500
if [[ ("$1" == "-tr") ]]; then
redshift -x
redshift -P -O $curtemp
exit 0
fi
echo $curtemp
below_threshold=$(echo "$curtemp <= 1500" | bc)
if [[ $below_threshold -eq 1 ]]; then
INCR=100
fi
if [[ ("$1" == "-ti") ]]; then
new=$(echo "$curtemp+$INCR" | bc)
elif [[ ("$1" == "-td") ]]; then
new=$(echo "$curtemp-$INCR" | bc)
fi
echo $new
valid=$(echo "$new >= 0 && $new <= 6500" | bc)
if [[ $valid -eq 1 ]]; then
redshift -P -O $new -b $curbrightness
echo $new > $DIRNAME/cur_temp
fi
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
esac
done