-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconky_weather.pl
executable file
·44 lines (39 loc) · 989 Bytes
/
conky_weather.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
use strict;
use warnings;
#
# Fetches weather from wunderground.com and displays in a format
# suitable for conky
#
use LWP::Simple;
my $station = "KHIO";
my $raw_weather = get("http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=" . $station);
if ($raw_weather =~ m/full>(.*?)<\/full/) {
my $val = $1;
print "$val\n";
}
if ($raw_weather =~ m/temperature_string>(.*?)<\/temperature_string/) {
my $val = $1;
$val =~ s/ F/°F/;
$val =~ s/ C/°C/;
print " $val";
}
if ($raw_weather =~ m/weather>(.*?)<\/weather/) {
my $val = $1;
print " - $val\n";
}
if ($raw_weather =~ m/wind_string>(.*?)<\/wind_string/) {
my $val = $1;
$val =~ s/^From/Wind from/;
print " $val\n";
}
if ($raw_weather =~ m/pressure_string>(.*?)<\/pressure_string/) {
my $val = $1;
print " $val\n";
}
if ($raw_weather =~ m/dewpoint_string>(.*?)<\/dewpoint_string/) {
my $val = $1;
$val =~ s/ F/°F/;
$val =~ s/ C/°C/;
print " Dew point $val";
}