-
Notifications
You must be signed in to change notification settings - Fork 2
/
asplashscreen.sh
72 lines (69 loc) · 1.99 KB
/
asplashscreen.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
#!/bin/sh
ROOTDIR="/opt/retropie"
DATADIR="/home/pi/RetroPie"
RANDOMIZE="disabled"
REGEX_VIDEO="\.avi\|\.mov\|\.mp4\|\.mkv\|\.3gp\|\.mpg\|\.mp3\|\.wav\|\.m4a\|\.aac\|\.ogg\|\.flac"
REGEX_IMAGE="\.bmp\|\.jpg\|\.jpeg\|\.gif\|\.png\|\.ppm\|\.tiff\|\.webp"
do_start () {
local config="/etc/splashscreen.list"
local line
local re="$REGEX_VIDEO\|$REGEX_IMAGE"
case "$RANDOMIZE" in
disabled)
line="$(head -1 "$config")"
;;
retropie)
line="$(find "$ROOTDIR/supplementary/splashscreen" -type f | grep "$re" | shuf -n1)"
;;
custom)
line="$(find "$DATADIR/splashscreens" -type f | grep "$re" | shuf -n1)"
;;
all)
line="$(find "$ROOTDIR/supplementary/splashscreen" "$DATADIR/splashscreens" -type f | grep "$re" | shuf -n1)"
;;
list)
line="$(cat "$config" | shuf -n1)"
;;
esac
if $(echo "$line" | grep -q "$REGEX_VIDEO"); then
# wait for dbus
while ! pgrep "dbus" >/dev/null; do
sleep 1
done
omxplayer -o both -b --layer 10000 "$line"
elif $(echo "$line" | grep -q "$REGEX_IMAGE"); then
if [ "$RANDOMIZE" = "disabled" ]; then
local count=$(wc -l <"$config")
else
local count=1
fi
[ $count -eq 0 ] && count=1
[ $count -gt 20 ] && count=20
local delay=$((20/count))
if [ "$RANDOMIZE" = "disabled" ]; then
fbi -T 2 -once -t $delay -noverbose -a -l "$config" >/dev/null 2>&1
else
fbi -T 2 -once -t $delay -noverbose -a "$line" >/dev/null 2>&1
fi
fi
exit 0
}
case "$1" in
start|"")
do_start &
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
status)
exit 0
;;
*)
echo "Usage: asplashscreen [start|stop]" >&2
exit 3
;;
esac