Code:
#!/bin/sh
# play soundfile after certain amount of time
# using OpenBSD 'aucat(1)'
SOUNDFILE="/home/j65nko/thesilentforce/track01.wav"
while true ; do
printf "Time to wait (mm:ss) = "
read time
#time='0:10'
minutes=${time%:*}
seconds=${time#*:}
pause=$((minutes*60+seconds))
echo "Waiting $time (${pause} seconds) ...."
sleep ${pause}
echo =======================
echo Playing ${SOUNDFILE}
aucat -i $SOUNDFILE
echo ======================
done
A sample run, where I terminate the loop with Control-C:
Code:
$ ./alert-me
Time to wait (mm:ss) : 37:00
Waiting 37:00 (2220 seconds) ....
=======================
Playing /home/j65nko/thesilentforce/track01.wav
======================
Time to wait (mm:ss) = ^C