More from:

Conky Weather

Changes in formats for available weather information recently required me to revise my conky script. Conky can be installed from the Ubuntu / MINT repos or downloaded from github and documentation is on sourceforge or by the man page. This information is furnished AS IS – use it at your own risk. Most recent version of the GPL applies.

The following code is how I get my weather information directly from and display up to date weather information for my area. The code for surface weather observations is found on the Weather.Gov web page for your zip code and the state / county codes for weather alerts is at the bottom of the page here.  My code is KFWA and my county is INC003. Replace these with the ones appropriate for your area.

The recommended pull time for your area is in the xml file that you get from Here is a sample of part of the lines in that file showing the suggested pick time and frequency:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="latest_ob.xsl" type="text/xsl"?>
<current_observation version="1.0"
xmlns:xsi="" xsi:noNamespaceSchemaLocation="">
<credit>NOAA's National Weather Service</credit>
<title>NOAA's National Weather Service</title>
<suggested_pickup>15 minutes after the hour</suggested_pickup>
<location>Fort Wayne International Airport, IN</location>

The part of my .conkyrc script dealing with weather is as follows:

${color FFAA00}WEATHER ${hr 2}$color${font Verdana:size=9}
#${execi 3600 curl -s > wwraw.txt}
#${execi 3600 wget -q --output-document="walerts.xml"}
${color 00FF00}${exec cat wwraw.xml | sed -n '//p' | cut -d'>' -f2 | cut -d'<' -f1}${color}
${color 00FF00}${exec cat wwraw.xml | sed -n '//p' | cut -d'>' -f2 | cut -d'<' -f1}${color}
${color 888888}Wind: ${exec cat wwraw.xml | sed -n '//p' | cut -d'>' -f2 | cut -d'<' -f1}${color}
${color FFFF00}Humidity: ${exec cat wwraw.xml | sed -n '//p' | cut -d'>' -f2 | cut -d'<' -f1}% ${color}
${color 00FF00}Temperature: ${exec cat wwraw.xml | sed -n '//p' | cut -d'>' -f2 | cut -d'<' -f1}${color}
${color 888888}Dew Point: ${exec cat wwraw.xml | sed -n '//p' | cut -d'>' -f2 | cut -d'<' -f1}${color}
${color 888888}Pressure: ${exec cat wwraw.xml | sed -n '//p' | cut -d'>' -f2 | cut -d'<' -f1} in Hg${color}${font}
${font Verdana:style=bold:size=10}Warnings:${font}${color}
${exec cat walerts.xml | sed -n '/\/p' | cut -d'>' -f2 | cut -d'<' -f1}

Notice the two lines which I have commented out with the pound # sign. These fetch the surface weather observations and weather alerts from They are commented out in my conky script because I fetch them instead using cron, 15 minutes after each hour,  the time recommended by They don’t HAVE to be in the script but I leave them there in case I need to refer back to them at some future date, such as if I accidently delete my weather fetching bash script. Edit your crontab in terminal by typing “crontab -e”.

# m h dom mon dow command
15 * * * * ./

The .xml file provided by says what time is recommended to pull. I try to avoid pinging more frequently than needed as a matter of respect: the weather is updated once per hour so more frequent pulls achieve nothing useful and cost in bandwidth.

To pull the weather information I use a bash script as follows. Remember a bash script must be “executable” for your login. Search on linux permits if you need more information. I can let cron call this once per hour, and it is also called through my .bash_profile when I log in.

#pull weather from

wget -q --output-document="wwraw.xml"
wget -q --output-document="walerts.xml"

To have the script prevent excessive downloads, I use this complete bash script:

#pull weather from
#ONLY IF it has not been pulled recently
#weather is updated once per hour
# recommended time to pull is hour+15
# manually noted weather is updates about
# 54 minutes after the hour
#last_update: 20170826 JDN

# define minimum time lapse before new pull is permitted
declare -i MINAGE=22
echo 'Min age' $MINAGE

# calculate time lapsed since last pull
if [ -f wwraw.xml ];
declare -i LAPSE=$(( ( $(date +%s) - $(stat wwraw.xml -c %Y)) / 60 ))
echo 'Lapse' $LAPSE
declare -i LAPSE=999

# allow override of command line parameter #1 is --force
if [ -n "$1" ]; then declare -i FORCE=1; else declare -i FORCE=0; fi
echo force is $FORCE

# calculate if pull is permitted (boolean)
echo dopull is $DOPULL

# test time lapse vs. minimum time lapse to allow pull or override
# Check if file older
if [[ $(($DOPULL + $FORCE)) -gt 0 ]]; then
# debugging message output if pull was performed
echo "File was pulled $LAPSE minutes ago. Pulling new weather data"
# get surface observations
# file will have date / time from
wget -q --output-document="wwraw.xml"
# mark file with current time to prevent hammering
touch wwraw.xml
# get weather alerts
wget -q --output-document="walerts.xml"
# debugging message output if pull was not performed
echo "File was pulled $LAPSE minutes ago. Ignoring request to pull again."

unset FORCE
unset DOPULL
unset MINAGE
unset LAPSE
exit 0