Created
September 5, 2014 20:16
-
-
Save matthewbednarski/04686e071ddee118cfef to your computer and use it in GitHub Desktop.
a countdown timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IFS=: | |
set -- $* | |
param1=0 | |
param2=0 | |
param3=0 | |
if [ ${3} > 0 ]; then | |
param3=${3} | |
fi | |
if [ ${2} > 0 ]; then | |
param2=${2} | |
fi | |
if [ ${1} > 0 ]; then | |
param1=${1} | |
fi | |
secs=$(( (${param1} * 3600) + (${param2} * 60) + ${param3} )) | |
while [ $secs -gt 0 ] | |
do | |
sleep 1 & | |
printf "\r%02d:%02d:%02d" $((secs/3600)) $(( (secs/60)%60)) $((secs%60)) | |
secs=$(( $secs - 1 )) | |
wait | |
done | |
printf "\r%02d:%02d:%02d" 0 0 0 | |
paplay /usr/share/sounds/freedesktop/stereo/complete.oga | |
echo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment