From d4753f209596e77f9b3ed1f709e16f04e86b9af8 Mon Sep 17 00:00:00 2001 From: five-hundred-eleven Date: Tue, 27 Aug 2024 19:56:11 -0400 Subject: [PATCH] ambience script now has automatic timeout --- choose_random_ambience.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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