Page 1 of 1

Conky Weather

Posted: Mon Jul 17, 2017 1:16 pm
by Froggg
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/liveweat ... ocCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'
ut=`curl --connect-timeout 30 -s http://rss.accuweather.com/rss/liveweat ... ocCode\=$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

Re: Conky Weather

Posted: Thu Aug 17, 2017 6:04 pm
by zcot
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 & 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
				<img src="http://vortex.accuweather.com/phoenix2/images/common/icons/16_31x31.gif">
				</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&day=1</link> 
				<guid isPermaLink="false">http://www.accuweather.com/get/weather?locationid=14094_PC&day=1</guid>
				<description>High: 92 F Low: 77 F A stray afternoon t-storm <img src="https://vortex.accuweather.com/phoenix2/images/common/icons/17_31x31.gif" ></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&day=2</link> 
				<guid isPermaLink="false">http://www.accuweather.com/get/weather?locationid=14094_PC&day=2</guid>
				<description>High: 92 F Low: 76 F Partly sunny with a t-storm <img src="https://vortex.accuweather.com/phoenix2/images/common/icons/17_31x31.gif" ></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?

Re: Conky Weather

Posted: Mon Oct 02, 2017 10:08 am
by Termy
You might find /usr/bin/wget -q http://wttr.in/<LOCATION> -O - useful, where LOCATION is your location.