-
Notifications
You must be signed in to change notification settings - Fork 5
/
bash_roku.sh
executable file
·63 lines (55 loc) · 1.29 KB
/
bash_roku.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
#! /bin/bash
function find_roku {
for i in $(arp -a | awk '{print $2}' | sed "s/[(|)]//g"); do
curl $i:8060 &>/dev/null
if [[ "$?" == "0" ]]; then
export ROKU_IP=$i
fi
done
}
function roku {
if [[ ! $ROKU_IP ]]; then
find_roku;
fi;
if [[ ! $ROKU_IP ]]; then
echo "Player not found"
return 1
fi;
echo
echo "Your player is at $ROKU_IP"
echo
while [ TRUE ]; do
echo
echo "------------"
echo "k) Up"
echo "j) Down"
echo "h) Left"
echo "l) Right"
echo "v) Select"
echo "x) Play"
echo "b) Back"
echo "q) Quit"
read -n 1 key
echo "------------"
echo
if [[ $key == k ]]; then
echo up
curl -d "" http://$ROKU_IP:8060/keypress/Up
elif [[ $key == j ]]; then
curl -d "" http://$ROKU_IP:8060/keypress/Down
elif [[ $key == h ]]; then
curl -d "" http://$ROKU_IP:8060/keypress/Left
elif [[ $key == l ]]; then
curl -d "" http://$ROKU_IP:8060/keypress/Right
elif [[ $key == v ]]; then
curl -d "" http://$ROKU_IP:8060/keypress/Select
elif [[ $key == x ]]; then
curl -d "" http://$ROKU_IP:8060/keypress/Play
elif [[ $key == b ]]; then
curl -d "" http://$ROKU_IP:8060/keypress/Back
elif [[ $key == q ]]; then
return 0
fi
done
}
roku