#!/bin/bash
#------------------------------------------------------------------------
#
# A simple script to remind you do something
# every X number of minutes. It uses espeak
# to tell you a message then waits for a
# space bar to start the timer again.
#
# ctrl-c exits
#
# ./doeveryxminutes.sh [minutes integer] "Message to self string"
#
# Hope you ejoy,
# Phillip J Rhoades
#
#------------------------------------------------------------------------
# Initialize some things
xminutes=$1
themessage="$2"
###
tput civis #hide the cursor
#Bring the cursor back after ctrl-c
trap ctrl_c INT
function ctrl_c() {
tput cvvis
exit
}
#Loop those minutes
while [ 1 ]; do
secs=$(($xminutes * 60))
while [ $secs -gt -1 ]; do
theminutes=$(printf "%02d" $((m=(${secs}%3600)/60)))
theseconds=$(printf "%02d" $((s=${secs}%60)))
echo -ne "Countdown to \"$themessage\": $theminutes:$theseconds\033[0K\r"
sleep 1
: $((secs--))
done
echo $themessage |espeak >/dev/null
echo -ne "Press space to continue...\033[0K\r"
read -n1 -r -p "" key
done
Comments