#!/usr/bin/env perl # Example slave command showing how to easily add additional things to the bar. # # You can place this in ~/.local/bin, customize it and direct wmstatus.conf # towards by setting e.g.: command=~/.local/bin/wmstatus-weather.pl use strict; use warnings; use Time::Piece; use IO::Socket::INET; my $host = 'www.yr.no'; my $path = '/place/Czech_Republic/Prague/Prague/forecast.xml'; # Retrieve current weather information from the Norwegian weather service sub weather { # There are no redirects and it's not exactly confidential either my $sock = IO::Socket::INET->new( PeerAddr => $host, PeerPort => 'http(80)', Proto => 'tcp' ) or return '?'; print $sock "GET $path HTTP/1.1\r\n" . "Host: $host\r\n" . "Connection: close\r\n\r\n"; # Quick and dirty XML parsing is more than fine for our purpose my ($offset, $acceptable, $temp, $symbol) = (0, 0); while (<$sock>) { $offset = $1 * 60 if /utcoffsetMinutes="(.+?)"/; next unless /