#!/bin/bash

##########################################
# Usage message
##########################################
if  [[ -z  $1 ]]; then 
  echo -e "This will count down the mumber of minutes specified and then ring the bell\nUsage: timer.sh <# of minutes>\n"
  exit 1
fi

##########################################
# Countdown 
##########################################
minutes=$1
while [[ minutes  -gt 0 ]]; do
   echo "$minutes left"
   sleep 60
   let minutes=$minutes-1
done

##########################################
# Time's up dialog box
##########################################
exec wish << EOF
#  Create the main message window
message .m -text "*************  Time is up! **************" -background grey -foreground red
pack .m -expand true -fill both -ipadx 40 -ipady 20 

#  Create the main menu bar with a Help-About entry
menu .menubar
menu .menubar.help -tearoff 0
.menubar add cascade -label "Help" -menu .menubar.help -underline 0
.menubar.help add command -label "About Hello ..." \
     -accelerator "F1" -underline 0 \
     -command showAbout

#  Define a procedure - an action for Help-About
proc showAbout {} {
     tk_messageBox -message "Tcl/Tk\nHello Windows\nVersion 1.0" \
          -title "About Hello"
}

#  Configure the main window
wm title . "Hello Foundation Application"
. configure -menu .menubar -width 200 -height 150
bind . "<Key F1>" {showAbout}
EOF
