-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogilink
92 lines (82 loc) · 2.28 KB
/
logilink
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
83
84
85
86
87
88
89
90
91
#!/bin/sh
# Inspired by Gareth Cronin @ Medium
xinput disable "keyboard:`cat ~/.logilink/device`"
amixer () {
`which amixer` -q sset "Speakers" - $1 -M
}
mpc () {
`which mpc` -q -P `cat ~/.logilink/mpdsecret` $1
}
hascript () {
curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer `cat ~/.logilink/hasstoken`" -d '{"entity_id": "script.'$1'"}' http://localhost:8123/api/services/script/turn_on -o /dev/null
}
hashell () {
curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer `cat ~/.logilink/hasstoken`" http://localhost:8123/api/services/shell_command/$1 -o /dev/null
}
kodipopup () {
curl -s -X POST -H "content-type:application/json" "http://`cat ~/.logilink/kodisecret`@192.168.2.4:8080/jsonrpc" -d '{ "jsonrpc": "2.0", "id": "1", "method": "GUI.ShowNotification", "params": { "title":"'"$1"'", "message":"'"$2"'", "image":"http://192.168.2.3/cvlwc/gfx/Sevenstar.png", "displaytime":10000 } }' -o /dev/null
}
while true
do
KEY=`logikey`
case $KEY in
42) # Backspace
;;
83) # Num Lock
hascript "sound_settings_movie"
hashell "tv_input_hdmi1"
;;
84) # /
hascript "sound_settings_music"
;;
85) # *
hascript "sound_settings_gaming"
hashell "tv_input_hdmi2"
;;
86) # -
amixer "5-"
;;
87) # +
amixer "5+"
;;
88) # Enter
hascript "sound_settings_music"
hascript "random_album"
;;
89) # 1
;;
90) # 2
hascript "light_group_previous"
;;
91) # 3
;;
92) # 4
mpc "prev"
;;
93) # 5
mpc "toggle"
;;
94) # 6
mpc "next"
;;
95) # 7
ARTIST=`echo "currentsong" | nc -q 1 localhost 6600 | grep ^Artist: | cut -d " " -f 2-`
TITLE=`echo "currentsong" | nc -q 1 localhost 6600 | grep ^Title: | cut -d " " -f 2-`
kodipopup "$TITLE" "$ARTIST"
;;
96) # 8
hascript "light_group_next"
;;
97) # 9
;;
98) # 0
hascript "killswitch"
;;
99) # ,
hascript "sound_settings_music"
hascript "random_book"
;;
*) ;;
esac
done
xinput enable "keyboard:`cat ~/.logilink/device`"