-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhue_brightness_alter
executable file
·71 lines (56 loc) · 1.16 KB
/
hue_brightness_alter
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
#!/bin/bash
[[ $1 == "--debug" ]] || [[ $1 == "-d" ]] && . hue_debug
. hue_settings
connection_test
val=50
already_send="no"
convert_send() {
bri="0x$(printf '%02x' "${val}")"
echo ${val}
echo ${bri}
for lamp in ${array_lamps[@]}
do
dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_${lamp}/service0023/char0029 org.bluez.GattCharacteristic1.WriteValue array:byte:"${bri}" dict:string:variant:
done
echo
}
echo "brightness: [+/-/q] :"
while read -s -n 1 bri
do
case ${bri} in
+)
((val+=5))
if [[ $val -ge 254 ]]
then
val=254
echo -e "${val} = maximum brightness\n"
[[ ${already_send} == "no" ]] && convert_send
already_send="yes"
else
convert_send
already_send="no"
fi
;;
-)
((val-=5))
if [[ $val -le 1 ]]
then
val=1
echo -e "${val} = minimum brightness\n"
[[ ${already_send} == "no" ]] && convert_send
already_send="yes"
else
convert_send
already_send="no"
fi
;;
q)
echo -e "bye bye (;-)\n"
break
;;
*)
echo -e "Please just use + or - or (q)uit.\n"
;;
esac
done
[[ $1 == "--debug" ]] || [[ $1 == "-d" ]] && characteristic_values