forked from samrocketman/home
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delay-start-kodi.sh
executable file
·51 lines (45 loc) · 1.08 KB
/
delay-start-kodi.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
#!/bin/bash
#Created by Sam Gleske
#Mon 16 May 18:54:38 PDT 2016
#Raspbian GNU/Linux 8
#Linux 4.4.9-v7+ armv7l
#GNU bash, version 4.3.30(1)-release (arm-unknown-linux-gnueabihf)
#gcc (Raspbian 4.9.2-10) 4.9.2
#DESCRIPTION
#Delay starting kodi for 5 seconds unless SHIFT is pressed.
#Depends on src/getkey.c being compiled and in the $PATH
function shiftkey() (
#get a device
device="$(ls -1 /dev/input/by-id/*-kbd | head -n1)"
if [ ! "$#" -eq 1 ]; then
return 1
fi
getkey $device $1
)
function startkodi() (
count=5
SHIFT=0
while [ "$count" -gt 0 -a "$SHIFT" = "0" ]; do
echo "(Press SHIFT to cancel) Starting kodi in... $count"
((count--))
sleep 1
#holding the right or left shift key?
if ! (shiftkey lshift && shiftkey rshift); then
SHIFT=1
fi
done
if [ "$SHIFT" -eq 0 ]; then
echo "Starting kodi..."
command kodi-standalone
else
echo "Canceled starting kodi."
fi
)
#only start kodi if GUI is not running
if ! pgrep openbox &> /dev/null; then
if ! type -pP kodi; then
echo "kodi not installed."
exit 1
fi
startkodi
fi