or: tm [min]
examples "tm 20:5" (20 min, 5 sec)
"tm 30" (30 min)
"tm :5" (5 sec)
"tm :10 bark.au" (10 seconds, plays bark.au)
Comes with gong-burmese.wav, which it plays by default.
Main script:
Code: Select all
#!/bin/sh
### Command line Timer jpeps 1/11
## Help
## Sound path is /usr/share/audio
if [ "$1" == "" -o "$1" == "-h" ]; then
echo "USAGE: [min]:[sec] [sound]"
echo "USAGE: [min]"
echo "sound path: /usr/share/audio"
exit
fi
dir="/usr/share/audio/"
## Set Sound
if [ "$2" ]; then
snd="$2"
else
snd="gong-burmese.wav"
fi
sep="$(echo ${1} | grep ":")"
min="$(echo ${1} | cut -d":" -f1)"
[ "$min" ] || min="0"
sec="$(echo ${1} | cut -d":" -f2)"
[ "$sec" ] || sec="0"
tmin="$((${min}*60 ))"
## Allow for entree without ":" for minutes
if [ "$sep" == "" ]; then
tsec="$((${1}*60))"
else
tsec="$((${tmin}+${sec}))"
fi
x="tsec"
n="0"
for ((i=0;i<=${x};i++)); do
n="$((${n} + 1))"
if [ "$n" == "${tsec}" ]; then
aplay ${dir}${snd} 2>/dev/null
fi
sleep 1
done
exit