diff options
Diffstat (limited to 'kachelmann')
-rw-r--r-- | kachelmann/.conditions.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | kachelmann/.gitignore | 2 | ||||
-rw-r--r-- | kachelmann/changes | 31 | ||||
-rwxr-xr-x | kachelmann/conditions | 7 | ||||
-rwxr-xr-x | kachelmann/conditions.pl | 7 |
5 files changed, 36 insertions, 11 deletions
diff --git a/kachelmann/.conditions.swp b/kachelmann/.conditions.swp Binary files differnew file mode 100644 index 00000000..a7b2f79d --- /dev/null +++ b/kachelmann/.conditions.swp diff --git a/kachelmann/.gitignore b/kachelmann/.gitignore new file mode 100644 index 00000000..050dfb2e --- /dev/null +++ b/kachelmann/.gitignore @@ -0,0 +1,2 @@ +conditions.pl +.*.swp diff --git a/kachelmann/changes b/kachelmann/changes new file mode 100644 index 00000000..dfd22b64 --- /dev/null +++ b/kachelmann/changes @@ -0,0 +1,31 @@ +#!/usr/bin/perl +use XML::Simple; +my $xml = new XML::Simple; +my $data_new = undef; +my $data_old = undef; + + +&startup; +while (true) { + if($status_new != $status_old){ + system("espeak -v de \"Das Wetter hat sich von $status_old in $status_new verändert\""); + } + sleep(300); + &get_status; +} + + +# The startup sub is used to get the first weather state. it should only be used on startup. sorry. +sub startup(){ + system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); + $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml"); + $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data}; +} + +# The get_status sub moves the current data to $data_old and then gets a new one from Googles API +sub get_status(){ + system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); + $data_old = $data_new; + $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml"); + $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data}; +} diff --git a/kachelmann/conditions b/kachelmann/conditions index 1a798e42..ea4ba5ca 100755 --- a/kachelmann/conditions +++ b/kachelmann/conditions @@ -1,7 +1,6 @@ #!/usr/bin/perl use XML::Simple; -system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); +my $result = `w3m -dump "http://www.google.com/ig/api?weather=70327-stuttgart&hl=de"`; my $xml = new XML::Simple; -my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); -my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Zelsius\n"; -system("espeak -v de \"$sentence\""); +my $data = $xml->XMLin($result); +print ("Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Zelsius\n"); diff --git a/kachelmann/conditions.pl b/kachelmann/conditions.pl deleted file mode 100755 index 6d8b5541..00000000 --- a/kachelmann/conditions.pl +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/perl -use XML::Simple; -system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); -my $xml = new XML::Simple; -my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); -my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n"; -system("espeak \"$sentence\""); |