1
0
Fork 0
RandomVideo/RandomVideo.sh

35 lines
587 B
Bash
Executable File

#!/bin/sh
folder=/mnt/video
player=omxplayer
if [ $# -eq 0 ]; then
echo "Parameter fehlt"
exit 1
fi
if [ $# -gt 1 ]; then
echo "Zu viele Parameter"
exit 1
fi
if [ "buzzer" != "$1" -a "cron" != "$1" ]; then
echo "Parameter muss \"buzzer\" oder \"cron\" sein"
exit 1
fi
if $(command -v pgrep) omxplayer > /dev/null; then
if [ "$1" = "buzzer" ]; then
$(command -v pkill) omxplayer
elif [ "$1" = "cron" ]; then
exit 0
fi
else
playerpath=$(command -v "$player")
$playerpath "$(find "$folder" -maxdepth 1 ! -name "$(basename $folder)"|sort -R |head -n1)" &
fi