You are not logged in.
just came looking for this. still works. thanks a lot, use it for a motd.
Offline
Check out this one:
http://ubuntuforums.org/showthread.php?t=869328
Last edited by SanskritFritz (2009-04-06 07:06:31)
zʇıɹɟʇıɹʞsuɐs AUR || Cycling in Budapest with a helmet camera || Revised log levels proposal: "FYI" "WTF" and "OMG" (John Barnette)
Offline
Oh, cool. This is a neat script, thanks!
[ lamy + pilot ] [ arch64 | wmii ] [ ati + amd ]
Offline
Here's a variation on this script that I made. I think it formats the output a little nicer.
#!/bin/sh
METRIC=1 # 0 for F, 1 for C
curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 \
| sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \L\1/p'
It returns something like "17°C, mostly sunny". You can remove the "\L" if you don't like lowercase letters as much as I do.
Last edited by fflarex (2009-06-15 15:22:34)
Offline
Could one somehow use the weather font with this script? I.e. update the icon based on the condition?
Arch x64 on Thinkpad X200s/W530
Offline
Yeah, it wouldn't really be that hard, but it would be very tedious to set up initially. It would also turn this one-liner into a much longer script. Not worth it, in my opinion, as there are existing weather scripts that make use of that font that I've seen around the forums.
Offline
Yeah, it wouldn't really be that hard, but it would be very tedious to set up initially. It would also turn this one-liner into a much longer script. Not worth it, in my opinion, as there are existing weather scripts that make use of that font that I've seen around the forums.
Like pogodynka (it's in AUR).
Offline
thanks for the script! after a little work, it's working great for me.
i was wondering how i could change the script to output: "condition ##F" i.e. "Partly Sunny 96F" WITHOUT the colon after the condition as is the normal output (Partly Cloudy: 96F). i tried to learn a bit of perl and look at the script a bit but can't seem to figure it out.. any perl-comfortable people know how?
@fflarex: i used your script, but it outputs on my desktop as "17A°C, mostly sunny" but i can't get the "A" to go away...
Last edited by ak00 (2009-06-20 21:46:54)
Offline
@ak00: Can you replace line 6 in my script with "| grep Currently:" (instead of the huge sed command) and post the output you get? It might help me figure out what went wrong in your case.
Last edited by fflarex (2009-06-20 22:22:59)
Offline
@ak00: Can you replace line 6 in my script with "| grep Currently:" (instead of the huge sed command) and post the output you get? It might help me figure out what went wrong in your case.
it outputs: "<title>Currently: Partly Sunny: 35" (without the quotes) . . .
the current code i use is:
curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'
and it outputs: "Partly Sunny: 95F"
what i want is 95° partly sunny or partly sunny 95° .. like your script just without the colon or C/F marker.. thanks for your help.
Offline
@ak00: Well I really have no idea what was causing that A to show up when you used my script. Maybe you copied my script wrong? I don't mean to place the blame on you but I really can't figure it out.
Anyways, here's a variation of my script to get the format you want. Let me know if it works for you:
#!/bin/sh
METRIC=1 # 0 for F, 1 for C
curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 \
| sed -n '/Currently:/ s/.*: \(.*\): \([-0-9]*\)\([CF]\).*/\2° \L\1/p' | sed 's/A°/°/'
If you want the conditions in front of the temperature change "/\2° \L\1/" to "/\L\1 \2°/".
Last edited by fflarex (2009-12-12 20:03:36)
Offline
yea still not much luck ... i'll just play around a bit more.. it COULD be because i am trying it on crunchbang.. and i have had an experience in the past where conky works a little different on one distro than another though i don't know why it would... thanks for your help though man! i appreciate it!!
right now my desktop is:
so you kind of see the essential info thing i'm trying to go for..
Offline
I've edited the script above. This is an ugly hack, but might get rid of the extra A you seem to be having troubles with.
Offline
hmmm im using your original script right now but just without the ° symbol.. i think the problem is the way my computer wants to render the ° sign. it produces "95F mostly cloudy" ... thanks!
Offline
The weather thingy isn't working. I'm getting this error when I load up conky:
/home/eddy/bin/weather.sh: 17: curl: not found
This is the code I use in my config file:
WEATHER ${hr 2}
${voffset 8}${font Arial Black:size=14}${alignc}${execi 300 /home/eddy/bin/weather.sh "EUR|UK|UK126|Coventry"}
And this is the weather.sh (the same as the weather.sh script at the start of this post):
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/liveweat … ocCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'
Is there something I'm doing wrong?
Offline
The weather thingy isn't working. I'm getting this error when I load up conky:
/home/eddy/bin/weather.sh: 17: curl: not found
..
Is there something I'm doing wrong?
you missed to install curl from extra
anyway, I'm trying this but now it doesn't work. It simply runs but it returns nothing. Does anyone have this problem too?
Last edited by Berseker (2009-12-12 08:41:26)
Offline
I started having troubles with my variant of it a couple weeks ago. I realized I hadn't taken sub-zero temperatures into account. Easy fix, just change [0-9] in the sed expression to [-0-9]. I edited my earlier post with the fix.
Offline
i'm happily using this script and it works great, thanks!
Desktop/Laptop - DWM :: VM - screen
Registered Linux User Number 483137 :: Victory! :: GitHub
Offline
Here's a one liner for dumping the yahoo forecast into a file to be read by conky:
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USAZ0052&u=f"| sed -e '/F<BR\|Low/!d; s/<.*>//'
Change the USAZ0052 to the code for your locale. If you want celsius, change the '=f' to '=c' and 'F<BR' to 'C<BR'.
My matching cron job to save it to a file:
30 * * * * <home>/bin/myweather.sh > /dev/shm/weather-update.txt
Sample output:
$ cat /dev/shm/weather-update.txt
Mostly Cloudy, 45 F
Sat - Showers Late. High: 49 Low: 41
Sun - Showers. High: 48 Low: 34
Edit: removed a superfluous grep
Last edited by Kitty (2009-12-13 00:40:11)
/etc/rc.d/ is where daemons reside. Beware.
Offline
Just customized the script so that it uses wget and awk (both I prefer ). Plus it reads weather condition for Currently, Today and Tomorrow.
# !/usr/bin/bash
METRIC=1 #Should be 0 or 1; 0 for F, 1 for C
if [ -z $1 ]; then
echo "USAGE: weather.sh <locationcode>"
exit 0;
fi
wget -q http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 -O - | awk \
'/Currently:/ {CurWeather=$0}
/[0-9] Forecast<\/title>/ {nr=NR+5}
NR==nr {postIndx[++x]=$0}
# x>2 {exit}
END{
split(CurWeather,tmp,"Currently: ")
split(tmp[2],tmp1,"<")
CurWeather=sprintf("%s",tmp1[1])
sub(":",",",CurWeather)
for(x in postIndx){
split(postIndx[x],tmp,";|&")
split(tmp[1],tmp,">")
split(tmp[2],statement," C ") # substitute C for F if metric differs
split(tmp[2],temp)
forecast[++y]=sprintf("%d-%dC %-15s",temp[5],temp[2],statement[3])
}
printf("WEATHER: %s\n%s\n%s",CurWeather,forecast[1],forecast[2])
}'
Last edited by kaikaizi (2010-05-11 19:04:32)
Offline
Just customized the script so that it uses wget and awk (both I prefer ), and you don't need to install curl and perl.
How in the world do you get by in arch without perl?
Offline
kaikaizi wrote:Just customized the script so that it uses wget and awk (both I prefer ), and you don't need to install curl and perl.
How in the world do you get by in arch without perl?
You're right. I am just more comfortable using awk
Offline
removed
Last edited by orphius1970 (2010-06-14 06:35:40)
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
Just customized the script so that it uses wget and awk (both I prefer ). Plus it reads weather condition for Currently, Today and Tomorrow.
# !/usr/bin/bash METRIC=1 #Should be 0 or 1; 0 for F, 1 for C if [ -z $1 ]; then echo "USAGE: weather.sh <locationcode>" exit 0; fi wget -q http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 -O - | awk \ '/Currently:/ {CurWeather=$0} /[0-9] Forecast<\/title>/ {nr=NR+5} NR==nr {postIndx[++x]=$0} # x>2 {exit} END{ split(CurWeather,tmp,"Currently: ") split(tmp[2],tmp1,"<") CurWeather=sprintf("%s",tmp1[1]) sub(":",",",CurWeather) for(x in postIndx){ split(postIndx[x],tmp,";|&") split(tmp[1],tmp,">") split(tmp[2],statement," C ") # substitute C for F if metric differs split(tmp[2],temp) forecast[++y]=sprintf("%d-%dC %-15s",temp[5],temp[2],statement[3]) } printf("WEATHER: %s\n%s\n%s",CurWeather,forecast[1],forecast[2]) }'
This is how it looks on my desktop:
WEATHER: Partly Sunny, 18C
10-21C Partly sunny
9-18C Rather cloudy, showers around
I wish it to looks like this:
WEATHER:
Now: 18C - Partly sunny
Today: 10-21C - Partly sunny
Tomorrow: 9-18C - Rather cloudy, showers around
How to achieve this?
Last edited by webmasteryoda (2011-04-27 16:45:50)
Offline
Change the last line to
printf("WEATHER:\nNow: %s\nToday: %s\nTomorrow: %s",CurWeather,forecast[1],forecast[2])
Offline