RandomVideo/RandomVideo.sh

45 lines
800 B
Bash
Executable File

#!/bin/sh
folder="/mnt/video"
player="cvlc"
playerparam="--play-and-exit --quiet --no-osd -A alsa --alsa-audio-device=front:CARD=Device,DEV=0"
pgrepplayer="vlc"
swupgpio=23
swdowngpio=25
swupstat=$($(command -v gpio) read $swupgpio)
if [ $# -eq 0 ]; then
echo "Parameter fehlt"
exit 1
fi
if [ $# -gt 1 ]; then
echo "Zu viele Parameter"
exit 1
fi
if [ $swupstat -eq 1 ]; then
exit 1
fi
if [ "buzzer" != "$1" ] && [ "cron" != "$1" ]; then
echo "Parameter muss \"buzzer\" oder \"cron\" sein"
exit 1
fi
if $(command -v pgrep) "$pgrepplayer" > /dev/null; then
if [ "$1" = "buzzer" ]; then
$(command -v pkill) "$pgrepplayer"
elif [ "$1" = "cron" ]; then
exit 1
fi
else
$(command -v "$player") $playerparam "$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)" &
fi