#!/bin/sh XMLF="KMSP.xml" FNAME="KMSP.png" # Create 166 x 90 darkgrey background image convert -size 166x90 xc:grey $FNAME # Parse the XML file and set up print strings TX01="Minneapolis, MN 55401" TX02=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1` TX04=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1 | cut -d' ' -f3- | sed -e 's/Northwest/NW/g' -e 's/Southwest/SW/g' -e 's/Northeast/NE/g' -e 's/Southeast/SE/g'` TX05a=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1` TX05="${TX05a}% Humidity" TX06a=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1 | cut -d' ' -f4-7 | sed -e 's/pm/PM/g' | sed -e 's/am/AM/g'` TX06="Updated: ${TX06a}" # Wind chill and heat factor are a mess. TX03a=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1` TX03c=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1` TX03h=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1` if [ $TX03a -ge 80 ] then if [ "$TX03h" = "NA" ] then TX03="${TX03a}F (${TX03a} Heat Fact)" else TX03="${TX03a}F (${TX03h} Heat Fact)" fi elif [ $TX03a -le 40 ] then if [ "$TX03c" = "NA" ] then TX03="${TX03a}F (${TX03a} Windchill)" else TX03="${TX03a}F (${TX03c} Windchill)" fi else TX03="${TX03a}F (${TX03a} Heat Fact)" fi # Write the text strings to the image convert $FNAME -font ./TimesBold.ttf -pointsize 14 -draw "text 3,14 '$TX01'" $FNAME convert $FNAME -font ./HelveticaNeue.ttf -pointsize 12 -draw "text 62,29 '$TX02'" $FNAME convert $FNAME -font ./HelveticaNeue.ttf -pointsize 12 -draw "text 62,43 '$TX03'" $FNAME convert $FNAME -font ./HelveticaNeue.ttf -pointsize 12 -draw "text 62,57 '$TX04'" $FNAME convert $FNAME -font ./HelveticaNeue.ttf -pointsize 12 -draw "text 62,71 '$TX05'" $FNAME convert $FNAME -font ./HelveticaNeue.ttf -pointsize 12 -draw "text 3,85 '$TX06'" $FNAME # Put in the icon, substitute N/A if not found ICN=`grep '' $XMLF | cut -d'>' -f2 | cut -d'<' -f1` if [ ! -f icons/$ICN ] then ICN="na.png" fi composite -geometry +4+16 icons/$ICN $FNAME $FNAME exit