In Hope of Nice Weekend Weather

Maybe I’m just desperate for a nice weather weekend, or I wanted to practice my skills for work, but I created this quick little bash script that runs on the 29 and 59 minutes of each hour, so I get the latest NOAA forecast for the weekend, hot off the presses displayed on my screen for the weekend.

#!/bin/bash

wget "https://forecast.weather.gov/MapClick.php?lat=42.4686&lon=-73.9294&unit=0&lg=english&FcstType=dwml" -O /var/tmp/forecast.xml

WEEKENDS=( Friday Saturday Sunday  )

for WEEKEND in "${WEEKENDS[@]}"
do
	DAY=$(xmllint /var/tmp/forecast.xml --xpath '/dwml/data/time-layout[2]/start-valid-time' | awk /$WEEKEND\"/'{print NR}')
	DAY12=$(xmllint /var/tmp/forecast.xml --xpath '/dwml/data/time-layout[1]/start-valid-time' | awk /$WEEKEND\"/'{print NR}')
	DAY12NIGHT=$((DAY12+1))
	HIGH=$(xmllint /var/tmp/forecast.xml --xpath "/dwml/data/parameters/temperature[@type=\"maximum\"]/value[$DAY]/text()" 2>/dev/null)
	LOW=$(xmllint /var/tmp/forecast.xml --xpath "/dwml/data/parameters/temperature[@type=\"minimum\"]/value[$DAY]/text()" 2> /dev/null)
	DAYSUMMARY=$(xmllint /var/tmp/forecast.xml --xpath "string(/dwml/data/parameters/weather/weather-conditions[$DAY12]/@weather-summary)" 2> /dev/null)
	NIGHTSUMMARY=$(xmllint /var/tmp/forecast.xml --xpath "string(/dwml/data/parameters/weather/weather-conditions[$DAY12NIGHT]/@weather-summary)" 2> /dev/null)
 
	[[ $WEEKEND == Saturday ]] && xmllint /var/tmp/forecast.xml --xpath "/dwml/data/parameters/conditions-icon/icon-link[$DAY12]/text()" 2> /dev/null | wget -i - -O /var/tmp/wxicon.png	


	[[  -z $HIGH ]] || OUTPUT+="\n $WEEKEND: "
	[[  -z $HIGH ]] || OUTPUT+="$DAYSUMMARY $HIGH "
	[[  -z $LOW ]]  || OUTPUT+="/ $NIGHTSUMMARY $LOW"

done
notify-send "Weekend Weather Update" "$OUTPUT" -t 15000 -i /var/tmp/wxicon.png

Map: Alma Pond
Map: Dobbins Memorial State Forest
Map: Little John Wildlife Management Area
Map: Otter Lake
Map: South Hill State Forest (Oneida 23)
Map: Summer Hill State Forest
Map: West Parishville State Forest
SVGZ Graphic: albany-snow-depth
SVGZ Graphic: college-rate
SVGZ Graphic: december-holidays
SVGZ Graphic: ht2025
SVGZ Graphic: lt2025
SVGZ Graphic: Places Named Bethlehem
SVGZ Graphic: Towns with Most Similiar Land Cover to the Town of Bethlehem
Terrain Map: Happy World Milk Day!
Photo: Stairs
Photo: Sun
Photo: Cannon
Photo: Off the ski run
Photo: Grafton Lakes
Photo: Some days are nicer than others
Photo: Very Neat Fireplace
Photo: Trail
Photo: Nice Clear Water
Photo: Wetlands Across the Canal

Leave a Reply

Your email address will not be published. Required fields are marked *