#!/bin/bash setime="$H $M" soundit=0 direxist () { if [[ -d ~/.alarm/ ]] then echo "" else mkdir ~/.alarm fi } mp3exist () { if [[ -e ~/.alarm/alarm.mp3 ]] then echo "" else echo "No alarm.mp3 found in ~/.alarm. Please copy an mp3 to the filename ~/.alarm/alarm.mp3"; exit fi } doesmplayer () { which mplayer &>/dev/null if [ $? != "0" ]; then echo -e "mplayer is not installed"; read -p "press enter to continue" var exit; fi } alarm () { the_time=`date "+%H %M"` echo -ne "\b\b\b\b\b\b\b" echo -ne "$the_time" if [[ "$the_time" == "$H $M" ]] then echo -ne "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bYour alarm is going off!"; mplayer ~/.alarm/alarm.mp3 &> /dev/null; soundit=1 exit else sleep .01 fi } setalarm () { read -p "What hour (24h format - eg 13 hours is 1 pm) would you like the alarm to go off: " H read -p "How many minutes past the hour would you lke the alarm to go off (for on the hour put 00 and any number under 10 type 0 in front of it: " M echo "Alarm is set for $H $M" } doesmplayer direxist mp3exist setalarm while (("$soundit" == "0")) do alarm done