there is a mediatation timer i use. which can help you.
it plays the wave files that stored in ~/.meditate to warn
thx flightlessbird for script.
Code:
#!/bin/bash
#http://flightlessbird.vox.com/library/post/meditation-timer.html
#author: flightlessbird
usage ()
{
echo -e "\033[1mUsage\033[0m: `basename $0` -slt"
echo '-s [number] number of stages, eg 5'
echo '-l [time] length of each stage
either in seconds, eg 300
or in format MIN:SEC, eg 5:00'
echo '-t [time] total time for practice
either in seconds, eg 1500
or in format MIN:SEC, eg 25:00'
echo "-l and -t are not compatible, only one can be used at a time"
}
lengthconvert ()
{
if echo $1 | grep -q :
then
MIN=$(echo $1 | sed 's/:.*//')
SEC=$(echo $1 | sed 's/.*://')
TOTALLENGTH=$[($MIN*60)+$SEC]
else
TOTALLENGTH=$1
fi
echo $TOTALLENGTH
}
bell ()
{
play $HOME/.meditate/*.wav &> /dev/null
}
countdown ()
{
TIMER=$1
MAXLEN=${#TIMER}
echo -n "$TIMER"
until [ $TIMER = 0 ]
do
sleep 1
DELENDA=$MAXLEN
until [ $DELENDA = 0 ]
do echo -ne "\b"
let DELENDA-=1
done
let TIMER-=1
echo -n $TIMER
GAP=$[$MAXLEN-${#TIMER}]
while [ $GAP -gt 0 ]
do echo -n " "
let GAP-=1
done
done
echo -ne "\n"
}
#default options
STAGES=4
LENGTH=300
while getopts ":s:l:t:h" Option
do
case $Option in
s ) STAGES="$OPTARG";;
l ) LENGTH=$(lengthconvert "$OPTARG");;
t ) TOTALTIME=$(lengthconvert "$OPTARG");;
h ) usage
exit;;
? ) badopt="$OPTARG";;
esac
done
if [ $badopt ]
then
echo "ERROR: bad option $badopt"
exit 3
elif [[ $STAGES -le 0 || $LENGTH -le 0 ]]
then
echo "ERROR: invalid options"
exit 3
elif [[ $TOTALTIME && $LENGTH -ne 300 ]]
then
echo "ERROR: incompatible options - -s and -l cannot be used together"
exit 3
elif [ $TOTALTIME ]
then
LENGTH=$[$TOTALTIME/$STAGES]
fi
COUNTER=1
SECONDS=$[$LENGTH%60]
echo -n "$STAGES stages of $[$LENGTH/60] minutes"
if [ $SECONDS -gt 0 ]
then
echo -n ", $SECONDS seconds"
fi
echo " each"
until [ $COUNTER -gt $STAGES ]
do
echo "Stage $COUNTER of $STAGES"
countdown $LENGTH
bell
let COUNTER+=1
done
bell
exit