-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyee
executable file
·44 lines (40 loc) · 937 Bytes
/
yee
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
#!/bin/bash
if [ $(
source /etc/os-release
echo $NAME
) = Void ]; then
nc() {
openbsd-nc $@
}
fi
fn_send() {
ip=192.168.178.33
ping -c1 -W1 $ip >/dev/null &&
printf "{\"id\":1,$1}\r\n" | nc -q 1 $ip 55443 && return
echo "$ip not available"
}
hsv_set() {
fn_send '"method":"set_scene", "params": ["hsv", '$1', '$2', '$3']'
}
case $1 in
set | brightness)
[ $2 -lt 1 ] && fn_send '"method":"set_power","params":["off", "smooth", 500]' && exit
fn_send '"method":"set_power","params":["on","smooth",'200']'
fn_send '"method":"set_bright","params":['$2',"smooth",'200']'
;;
color | hsv)
hsv_set "$2" "$3" "$4"
;;
red)
fn_send '"method":"set_scene", "params": ["hsv", 0, 100, '${2:-100}'"]'
;;
blue)
fn_send '"method":"set_scene", "params": ["hsv", 245, 100, '${2:-100}'"]'
;;
green)
fn_send '"method":"set_scene", "params": ["hsv", 125, 100, '${2:-100}'"]'
;;
*)
fn_send '"method":"toggle","params":[,,]'
;;
esac