diff --git a/choose_random_ambience.sh b/choose_random_ambience.sh index 95d65e1..574a385 100644 --- a/choose_random_ambience.sh +++ b/choose_random_ambience.sh @@ -1,7 +1,22 @@ #!/bin/bash -set -ex +#set -ex + +duration=$1 + +if [ -z "$duration" ] +then + echo "Missing required argument duration, ex 20m" + exit 1 +fi + +echo "Duration: $duration" + choices=$(ls *ambience*.mp3) shuffled=$(printf "%s\n" "${choices[@]}" | shuf -n1) echo $shuffled -totem ${shuffled[ $RANDOM % ${#shuffled[@]} ]} +timeout $duration totem ${shuffled[ $RANDOM % ${#shuffled[@]} ]} +if [ $? -eq 124 ] +then + totem '/media/cowley/muninn/ambience/Maarten Schellekens - Spring Morning.mp3' +fi