-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathomx.sh
executable file
·103 lines (88 loc) · 2.71 KB
/
omx.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
CURDIR=$(dirname $0)
cd "$CURDIR"
# set here the path to the directory containing your videos
VideoLocation="./assets"
function terminate {
kill -SIGTRAP $PROC1 2>/dev/null
kill -SIGTERM $PROC1 2>/dev/null
kill -SIGTERM $PROC2 2>/dev/null
kill -SIGTERM $PROC3 2>/dev/null
kill -SIGINT $PROC1 2>/dev/null
kill -SIGINT $PROC2 2>/dev/null
kill -SIGINT $PROC3 2>/dev/null
echo -e "\e[33m\n\n"
echo -e "-----------------------------"
echo -e " LOOPING TERMINATED. "
echo -e "-----------------------------"
echo -e "\n\n"
trap SIGTERM
trap SIGINT
xset dpms force on
kill -SIGTERM $$ 2>/dev/null
}
trap terminate SIGINT
# trap 'echo int; kill -SIGINT $PROC1' SIGINT
trap terminate SIGTERM
for i in /media/*/*/rpi_player
do
if [ -d $i ]
then
for y in $i/assets/*
do
if [ -e $y ]
then
VideoLocation=/media/*/*/rpi_player/assets
fi
done
fi
done
echo "Video source: "$VideoLocation
# you can probably leave this alone
Process="omxplayer"
# our loop
xset dpms force off
function looping {
while true;
do
if ps ax | grep -v grep | grep $Process > /dev/null
then
echo "omx is running. Sleeping."
sleep 1;
else
for entry in $VideoLocation/*
do
xset dpms force off
# -r for stretched over the entire location
echo "$entry"
#volume set by daytime
time=$(node time.js)
hours=$(echo "$time" | head -n +1)
time=$(echo "$time" | tail -n -1)
volume=0
if [ "$time" == "day" ]
then
volume=-300
elif [ "$time" == "night" ]
then
volume=-1200
fi
echo "volume: $volume"
omxplayer.bin -b -o local --vol "$volume" "$entry" > /dev/null &
PROC1=$!
trap 'kill -SIGTRAP $PROC1 2>/dev/null; trap SIGTERM; break; terminate' SIGTERM
trap 'kill -SIGTERM $PROC1 2>/dev/null; trap SIGTERM; break; terminate' SIGTERM
trap 'kill -SIGINT $PROC1 2>/dev/null; trap SIGINT; break; terminate' SIGINT
wait
xset dpms force off
done &
PROC2=$!
trap 'kill -SIGTERM $PROC2 2>/dev/null; trap SIGINT; break; terminate' SIGTERM
trap 'kill -SIGINT $PROC2 2>/dev/null; trap SIGINT; break; terminate' SIGINT
wait
fi
done
}
looping &
PROC3=$!
wait