Conky Weather

Forum rules
Before you post please read how to get help
Froggg
Level 1
Level 1
Posts: 6
Joined: Thu Aug 07, 2014 1:22 pm

Conky Weather

Postby Froggg » Mon Jul 17, 2017 1:16 pm

Hi all. It's been a while since I've messed with Conky, and need some help. I've got a Conky widget that I run, which shows system info, local and UTC time. I would like to add the weather, and did a cut and paste and have been able to get it to show current conditions and temp, per Accuweather website. What I would like to show is wind direction and speed, humidity and barometric pressure, but I don't understand the lines in the bash script file that gathers the info. Included is the line from my conkyrc that calls the bash script file and the bash script file itself. Any and all help is greatly appreciated.

From my conkyrc:

${execi 300 bash /home/dave/weather.sh 45828}

My bash script file (entire):

#!/bin/sh
#AccuWeather (r) RSS weather tool for conky
#
#USAGE: weather.sh <locationcode>
#
#(c) Michael Seiler 2007

METRIC=0 #Should be 0 or 1; 0 for F, 1 for C

if [ -z $1 ]; then
echo
echo "USAGE: weather.sh <45828>"
echo
exit 0;
fi

curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'
ut=`curl --connect-timeout 30 -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'`

#echo $out

cond=`echo $out | cut -d':' -f 1`

temp=`echo $out | cut -d':' -f 2`

case "$cond" in

'Fog')
echo -e "Nombre\c"
;;
'Snow')
echo -e "Nevado\c"
;;
'Cloudy')
echo -e "Nublado\c"
;;
'Sunny')
echo -e "Ensolarado\c"
;;
'T-Storms')
echo -e "Pancada\c"
;;
*)
echo -e $cond'\c'
esac

echo $temp

zcot
Level 1
Level 1
Posts: 25
Joined: Wed Oct 19, 2016 6:08 pm

Re: Conky Weather

Postby zcot » Thu Aug 17, 2017 6:04 pm

You wont be able to do it using this method because that particular info is not provided by that accuweather call.


This is the command I used:

Code: Select all

curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=0\&locCode\=32712


and it returns this info:

Code: Select all

<?xml version = "1.0"?>
<rss version="2.0">
<channel>
<title>Apopka, FL - AccuWeather.com Forecast</title>
<link>http://www.accuweather.com/get/weather?locationid=14094_PC</link>

      <description>AccuWeather.com Forecast &amp; Current Conditions</description>
      <ttl>60</ttl>
      <copyright>Copyright 2017, AccuWeather, Inc., All rights reserved. For personal use only.</copyright>
      <pubDate>Thu, 17 Aug 2017 21:24:16 GMT</pubDate>
      <language>en-us</language>
      <image>
         <title>Apopka, FL - AccuWeather.com Forecast</title>
<link></link>

         <description>AccuWeather.com The Best Weather on the Web!</description>
         <url>http://vortex.accuweather.com/adc2004/pub/images/logos/adc_logo_187.gif</url>
         <width>144</width>
         <height>19</height>
      </image>      
      <item>
         <title>Currently: Mostly Cloudy W/ T-Storms: 89F</title>
         <link>http://www.accuweather.com</link>
         <guid isPermaLink="false">http://www.accuweather.com</guid>
         
            <description>Currently in Apopka, FL: 89 &#176;F and Mostly Cloudy W/ T-Storms
            &lt;img src="http://vortex.accuweather.com/phoenix2/images/common/icons/16_31x31.gif"&gt;
            </description>          
         
         <pubDate>Thu, 17 Aug 2017 21:24:16 GMT</pubDate>
      </item>
      
         <item>
            <title>8/17/2017 Forecast</title>
            <link>http://www.accuweather.com/get/weather?locationid=14094_PC&amp;day=1</link>
            <guid isPermaLink="false">http://www.accuweather.com/get/weather?locationid=14094_PC&amp;day=1</guid>
            <description>High: 92 F Low: 77 F A stray afternoon t-storm &lt;img src="https://vortex.accuweather.com/phoenix2/images/common/icons/17_31x31.gif" &gt;</description>
            <pubDate>Thu, 17 Aug 2017 21:24:16 GMT</pubDate>
         </item>
      
         <item>
            <title>8/18/2017 Forecast</title>
            <link>http://www.accuweather.com/get/weather?locationid=14094_PC&amp;day=2</link>
            <guid isPermaLink="false">http://www.accuweather.com/get/weather?locationid=14094_PC&amp;day=2</guid>
            <description>High: 92 F Low: 76 F Partly sunny with a t-storm &lt;img src="https://vortex.accuweather.com/phoenix2/images/common/icons/17_31x31.gif" &gt;</description>
            <pubDate>Thu, 17 Aug 2017 21:24:16 GMT</pubDate>
         </item>
      <item>
<title>The AccuWeather.com RSS Center</title>
<description>To discover additional weather feeds, visit the AccuWeather.com RSS Center at http://www.accuweather.com/en/downloads</description>
<link>http://www.accuweather.com/en/downloads</link>
<guid isPermaLink="false">http://www.accuweather.com/en/downloads</guid>
<pubDate>Thu, 17 Aug 2017 21:24:16 GMT</pubDate>
</item>
</channel>
</rss>


The info returns current, and a 2-day forecast.

Maybe you can discover additional weather feeds at The AccuWeather.com RSS Center in one of those links?

User avatar
Termy
Level 3
Level 3
Posts: 170
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Conky Weather

Postby Termy » Mon Oct 02, 2017 10:08 am

You might find /usr/bin/wget -q http://wttr.in/<LOCATION> -O - useful, where LOCATION is your location.
Here to help.


Return to “Compiz, Conky, Docks, & Widgets”