RandomVideo/RandomVideo.sh
Vieno Hakkerinen 172c2330f1 add unlicense as license of project
* use unlicense to put work into public domain and not care for anything
* https://unlicense.org/
2020-08-24 16:47:55 +02:00

34 lines
583 B
Bash
Executable file

#!/bin/sh
# SPDX-License-Identifier: Unlicense
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" ] && [ "cron" != "$1" ]; then
echo "Parameter muss \"buzzer\" oder \"cron\" sein"
exit 1
fi
if $(command -v pgrep) "$player" > /dev/null; then
if [ "$1" = "buzzer" ]; then
$(command -v pkill) "$player"
elif [ "$1" = "cron" ]; then
exit 1
fi
else
$(command -v "$player") "$(find "$folder" -maxdepth 1 -type f |sort -R |head -n1)" &
fi