#!/bin/sh # # time_announce v1.0 - A time announce # script for IRLP nodes. Requires Festival # (a text-to-speech engine) # # Written by Robert Pectol - kk7av # http://rob.pectol.com/irlp # ################################################# ################################# # USER CONFIGURABLE SETTINGS # ################################# # AUX line PTT support aux_line_ptt="no" aux_line="1" # report time in 12/24 hour time format time_format="12" ############################### # END USER SETTINGS # ############################### #################################################### # ---> NO NEED TO MODIFY BELOW THIS LINE! <--- # #################################################### # ensure script is run as repeater user if [ `/usr/bin/whoami` != "repeater" ] ; then exit 1 fi # ensure the environment file has been sourced if [ "$RUN_ENV" != "TRUE" ] ; then . /home/irlp/custom/environment fi # exit silently if there is a QSO in progress if ! $BIN/pttstate; then exit 0 fi if ! $BIN/cosstate; then exit 0 fi # en/disables time announcements if [ -f ~/.time_announce ]; then echo "Time announcements disabled! (remove ~/.time_announce to enable them)" exit 0 fi # for AUX line PTT support if [ "$aux_line_ptt" == "yes" ]; then tx_key=`echo "$BIN/aux$aux_line""on"` tx_unkey=`echo "$BIN/aux$aux_line""off"` else tx_key=`echo "$BIN/key"` tx_unkey=`echo "$BIN/unkey"` fi # set some script variables timestamp=`date` curhour_24=`date +%k` curhour_12=`date +%l` curminute=`date +%M` curday=`date +%u` if [ "$time_format" = "12" ]; then curhour=$curhour_12 else curhour=$curhour_24 fi if [ "$curminute" == "00" ]; then curminute="o clock" fi case $curminute in 01) curminute="oh, one" ;; 02) curminute="oh, two" ;; 03) curminute="oh, three" ;; 04) curminute="oh, four" ;; 05) curminute="oh, five" ;; 06) curminute="oh, six" ;; 07) curminute="oh, seven" ;; 08) curminute="oh, eight" ;; 09) curminute="oh, nine" ;; esac case $curday in 1) curday="monday" ;; 2) curday="tuesday" ;; 3) curday="wednesday" ;; 4) curday="thursday" ;; 5) curday="friday" ;; 6) curday="saturday" ;; 7) curday="sunday" ;; *) curday="I do not know what day it is." ;; esac # decide AM or PM based on the hour if [ "$curhour_24" -gt "11" ]; then speak_ampm="P,M" else speak_ampm="A,M" fi # decide if it's morning, afternoon, or evening if [ "$curhour_24" -lt "12" ]; then speak_greeting="morning" elif [ "$curhour_24" -gt "17" ]; then speak_greeting="evening" else speak_greeting="afternoon" fi # build the announcement if [ "$time_format" = "12" ]; then announce="Good $speak_greeting, the time is, $curhour, $curminute, $speak_ampm" else announce="Good $speak_greeting, the time is, $curhour, $curminute" fi # key up the node $tx_key usleep 500000 # announce the time echo $announce | festival --tts # un-key the node $tx_unkey # show time on stdout echo $timestamp exit 0