#!/bin/bash
#Sources
WBNG='http://**.**.***.**/*****/closings/sch.html'
LOCAL='/home/User/sch.html'
MSTR_SOURCE="$LOCAL"
DUMP='/home/User/closings_dump'
#End Sources
#Create a dumpfile
w3m -dump $MSTR_SOURCE > $DUMP
#Find a One Hour Delay
function check_one
{
if [ "$( grep -i "School Name" $DUMP )" = " School Name School District One Hour Delay" ] ;then
if [ "$(date +%H%M)" = "0545" ] ;then
sleep 1h
rm $DUMP
check_one
fi
if [ "$(date +%H%M)" = "0645" ] ;then
start_day
else
check_two
fi
fi
}
#End One Hour Delay
#Find a Two Hour Delay
function check_two
{
if [ "$( grep -i "School Name" $DUMP )" = " School Name School District Two Hour Delay" ] ;then
if [ "$(date +%H%M)" = "0545" ] ;then
sleep 2h
rm $DUMP
check_one
fi
if [ "$(date +%H%M)" = "0745" ] ;then
start_day
else
check_close
fi
}
#End Two Hour Delay
#Find a Cancellation
function check_close
{
if [ "$( grep -i "School Name" $DUMP )" = " School Name School District Closed" ] ;then
rm $DUMP
exit 0
else
start_day
fi
}
#End Cancellation
#No Delay
function start_day
{
####START MORNING#####
#Turn monitors & music on (norm 5:45am)
xset dpms force on
amarokapp --play
#Open today's weather page
firefox "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=*****"
#Send a TXT to 1st person
#dcopref=`dcop kmail KMailIface openComposer "address" "" "" "subject" "message" false`
#dcop "$dcopref" send 1
#These next few lines need to run at 6:20am
#dcopref=`dcop kmail KMailIface openComposer "address" "" "" "subject" "message" false`
#dcop "$dcopref" send 1
#This runs at 7:00am Turn monitors & music off
#amarokapp --stop
#xset dpms force off
#Clean up
rm $DUMP
exit 0
}
#Begin Delay Checking
check_one