You are not logged in.
Well, I tried weatherget and it consumes a lot of resources each time it checks. This just isn't good at all on systems that might depend on that CPU time for something else, like games. Plus it's distracting to see that silly CPU spike on the graph.
Requires curl and perl.
#!/bin/sh
#AccuWeather (r) RSS weather tool for conky
#
#USAGE: weather.sh <locationcode>
#
#(c) Michael Seiler 2007
METRIC=1 #Should be 0 or 1; 0 for F, 1 for C
if [ -z $1 ]; then
echo
echo "USAGE: weather.sh <locationcode>"
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"; }'
Change METRIC to suit your taste.
In your conkyrc, the line should be something like so:
${execi 300 /home/buttons/bin/weather.sh 08534}
Which produces (at the moment) "Mostly Sunny: 24C"
Note you can use anything for the (accuweather) location code and it should work. If you're not in the US, put your location code in quotes, like so:
${execi 300 /home/buttons/bin/weather.sh "EUR|UK|UK118|Amersham"}
Which produces "Mostly Clear: 15C"
Location codes can be found on accuweather's website, accuweather.com. Within the US, this is just the ZIP code.
Cthulhu For President!
Offline
Thanks!
Offline
works great. thanks!
Offline
Exactly what I was looking for. Thanks!
Offline
Is it okey if I use your script in a howto on a swedish wiki?
Offline
Is it okey if I use your script in a howto on a swedish wiki?
Yepper.
Cthulhu For President!
Offline
Thanks for the nice script! But I can't find the location codes on the website you mentioned. I'm living in Berlin, Germany. Do you have a link?
Offline
EUR|DE|GM003|BERLIN
The easiest way is to go to accuweather.com and search up your location. Once you've done that, take a look at the URL, which in this case is
http://www.accuweather.com/world-index- … cuweather&locCode=EUR|DE|GM003|BERLIN|&u=1
The bit in bold is the part to look for, which shows locCode (the location code) is EUR|DE|GM003|BERLIN
and
weather.sh "EUR|DE|GM003|BERLIN"
gives Rain/drizzle: 7C at the time of this writing, which is warm by northeast US winter standards
Cthulhu For President!
Offline
thanks alot! works perfect!
Unyttig.INFO - Your source to not so useless information
My github - Various configs, dotfiles and nifty scripts
Offline
Great! Useful.
Thanks!
Offline
Just a question:
Wouldn't it better and easy with the Weather Channel info?
Last edited by Lyceuhns (2008-07-27 18:29:25)
Offline
A quick tweak to include a default location, which can be over-ridden by the command line
Change the LOCCOD variable to your default location, then you can call it just by running the script. Or leave it blank and it will be ignored (printing the usage message if a command line argument isn't given.
#!/bin/sh
#AccuWeather (r) RSS weather tool for conky
#
#USAGE: weather.sh <locationcode>
#
#(c) Michael Seiler 2007
METRIC=1 #Should be 0 or 1; 0 for F, 1 for C
LOCCOD="" # Example: OCN|AU|VIC|MELBOURNE
if [ -z $1 ] && [ -x $LOCCOD ] ; then
echo
echo "USAGE: $0 [locationcode]"
echo
exit 0;
elif [ ! -z $1 ] ; then
LOCCOD=$1
fi
curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$LOCCOD | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'
Last edited by fukawi2 (2008-07-28 01:22:48)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Hi.
How to convert the state of the time for another language?
example:
Cloudy = Nublado
Sunny = Ensolarado
T-Storms = Pancada
....
Offline
Offline
Hi.
How to convert the state of the time for another language?
example:
Cloudy = Nublado
Sunny = Ensolarado
T-Storms = Pancada
....
Here you go... it should be straight forward on how to add a new item, just follow the syntax...
Feel free to ask any questions...
#!/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 <locationcode>"
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"; }'
out=`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
Offline
cool - works great!
The accuweather URL didn't list that info for me, so I just used my zip code. "weather.sh" seemed kind of generic, so I named mine "weatherconk"
Offline
Here you go... it should be straight forward on how to add a new item, just follow the syntax...
Feel free to ask any questions...
Thanks for help
Offline
Sure no problem...
Does anyone have a problem with the curl command hanging every now and then?
Same here. The script seems to lock up conky at least once a day. Not sure if it's something to do with curl or the connection to accuweather maybe? Whatever it is, I had to stop using it.
Offline
Conky reports
sh: /home/edio/.common/conky_weather.sh: Permission denied
How can I fix this?
Offline
Sure no problem...
Does anyone have a problem with the curl command hanging every now and then?
adding "--connect-timeout 30" to the curl options fixed this for me. your mileage may vary.
edit: oops.... just read back, that's already been mentioned.... by you, probably where i found it in the first place, circular linux hints ftw!
Last edited by brisbin33 (2009-03-06 21:08:45)
//github/
Offline
Great script!
Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.
Offline
Conky reports
sh: /home/edio/.common/conky_weather.sh: Permission deniedHow can I fix this?
You need to make it executable:
chmod +x /home/edio/.common/conky_weather.sh
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
fukawi2
Thank you... I tried all things about permissions, and setting them to rwxrwxrwx (oct: 0777) solves my problem.
But now I know, that I have to make scripts executable...
P.S. Looks like Linux is smarter, than I am %)
Offline
This script runs without problem here.
I use it in conky as explained in this post, and is very useful too in the CLI.
For example, if anyone is looking for, this is the location code for Mexico City, and running this
./clima.sh "NAM|MX|MX009|MEXICO_CITY"
in the CLI does the task.
Thanks Buttons!
Offline