#!/bin/bash
### BEGIN INIT INFO
# Provides: asplashscreen
# Required-Start: mountdevsubfs
# Required-Stop:
# Default-Start: S
# X-Start-Before: checkroot
# Default-Stop:
# Short-Description: Show custom splashscreen
# Description: Show custom splashscreen
### END INIT INFO
do_start () {
local config="/etc/splashscreen.list"
local line="$(head -1 "$config")"
if $(echo "$line" | grep -q ".avi\|.mov\|.mp4\|.mkv\|.3gp\|.mpg\|.mp3\|.wav\|.m4a\|.aac\|.ogg\|.flac"); then
# wait for /tmp to become writable
while ! touch /tmp/writable 2>/dev/null; do
sleep 1
done
rm -f /tmp/writable
omxplayer -b --layer 10000 "$line"
else
# local count=$(wc -l <"$config")
# [ $count -eq 0 ] && count=1
# [ $count -gt 20 ] && count=20
# local delay=$((20/count))
# fbi -T 2 -once -t $delay -noverbose -a -l "$config" >/dev/null 2>&1
declare -a splashs=(`find /opt/retropie/supplementary/splashscreen/ |grep png`)
max=${#splashs[@]}
wp=$((`cat /dev/urandom|od -N1 -An -i` % $max))
/usr/bin/fbi -T 2 -once -t 20 -noverbose -a ${splashs[$wp]} >/dev/null 2>&1
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
: