-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQcolor.sh
executable file
·82 lines (71 loc) · 1.4 KB
/
Qcolor.sh
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
76
77
78
79
80
81
82
#!/bin/bash
# Simple shell script to control Belleds Q station light colors
# Requires netcat (nc) and zenity to be installed
# 2015-02-22 Ronald McCollam <[email protected]>
dir="$(dirname $0)"
if ! . $dir/environment.conf ; then echo "Unable to load settings." && exit 1 ; fi
if ! . $dir/lib.sh ; then echo "Unable to load function library." && exit 1 ; fi
function sanityCheck()
{
if ! which zenity > /dev/null
then
echo "Zenity is not installed."
exit 1
fi
if ! which nc > /dev/null
then
echo "Netcat is not installed."
exit 1
fi
if ! which jq > /dev/null
then
echo "jq is not installed."
exit 1
fi
}
function usage()
{
echo "$0 - Control Belleds Q light bulbs"
echo
echo "Usage:"
echo " $0 [-l|--loop] [-h|--help]"
echo
echo " -l | --loop - Continue to loop through the color setting dialog until cancel is pressed (useful for tweaking specific colors)"
echo " -h | --help - Display this message"
}
ARGS=$(getopt -o l,h -l "loop,help" -n "$0" -- "$@");
eval set -- "$ARGS"
loop=0
while true
do
case "$1" in
-l|--loop)
loop=1
shift
;;
-h|--help)
usage
shift
exit 0
;;
--)
shift
break
;;
esac
done
sanityCheck
listBulbs
getBulbs
# Fake up a do...while loop (we always want to do this at least once)
keepGoing=1
until [ $keepGoing -ne 1 ]
do
getColor
JSON=$(buildColorJSON)
sendCommand $JSON
if [ $loop -ne 1 ]
then
keepGoing=0
fi
done