#! /bin/ksh

#
# Name        : ${HOME}/bin/time.ksh
#
# Version     : 1.0
#
# Author      : Gerard van Wageningen
#
# Description : Just another timer program
#
# 1.0   First Version
#

\whence set_debug 1>/dev/null 2>&1 && eval $( set_debug ${0##*/} )

typeset -i delay=380 # 6 \* 60 + 20 minutes
typeset text='End of the work period.'

case $# in
  0) ;;
  *)
    typeset delayStr="${1}"
    # TODO: translate string to minutes
    delay=${delayStr}
    shift 1
    text="${@}"
    ;; 
esac

sleep $(( delay \* 60 ))

if [[ -x '/usr/dt/bin/dtksh' ]]
then
  Alert.dtksh "${text}"
else
  print -u2 'Not implemented yet, bailing out...'
  exit 1
fi

exit 0

###################### EOF ######################
