diff --git a/RandomVideo.sh b/RandomVideo.sh index ddcd3c2..b04acf4 100755 --- a/RandomVideo.sh +++ b/RandomVideo.sh @@ -20,15 +20,6 @@ if [ -z "$(command -v $player)" ]; then exit 1 fi -folder="$(jq -r ".RandomVideo | .folder" < $configfile)" -playerparam="$(jq -r ".playerparam" < $configfile)" -pgrepplayer="$(jq -r ".pgrepplayer" < $configfile)" - -swupgpio="$(jq -r ".swupgpio" < $configfile)" - -playerfull="$(command -v $player) $playerparam" -swupstat="$(gpio read $swupgpio)" - if [ $# -eq 0 ]; then echo "Missing parameter!" exit 1 @@ -39,15 +30,24 @@ if [ $# -gt 1 ]; then exit 1 fi -if [ "$swupstat" -eq 1 ]; then - exit 1 -fi - if [ "buzzer" != "$1" ] && [ "cron" != "$1" ]; then echo "parameters must be \"buzzer\" or \"cron\"!" exit 1 fi +swupstat="$(gpio read $swupgpio)" +if [ "$swupstat" -eq 1 ]; then + exit 1 +fi + +folder="$(jq -r ".RandomVideo | .folder" < $configfile)" +playerparam="$(jq -r ".playerparam" < $configfile)" +pgrepplayer="$(jq -r ".pgrepplayer" < $configfile)" + +swupgpio="$(jq -r ".swupgpio" < $configfile)" + +playerfull="$(command -v $player) $playerparam" + if pgrep "$pgrepplayer" > /dev/null; then if [ "$1" = "buzzer" ]; then pkill "$pgrepplayer"