ambience script now has automatic timeout

This commit is contained in:
five-hundred-eleven
2024-08-27 19:56:11 -04:00
parent 9f34fcfba6
commit d4753f2095

View File

@@ -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