смотреть в будущее
11:21 | 22-10-2008 | HOWTO, Software | No Comments
для того, чтобы увидеть прогноз погоды на своем десктопе, можно немного изменить уже давно существующее решение:
#!/usr/bin/env perl # Grab all the lines and put in an array @w = <>; # Keep only certain lines for the current conditions @t = grep /^ +(Temperature \\d|Wind|Relative|Weather|Sky)/, @w; # Convert and modify existing values for (@t){ s/(\\d+) +MPH/int($1*0.44704)." m\\/s"/e; s/\\((\\d+ KT)\\)//; s/\\d+ F //; s/\\((\\d+ C)\\)/\\1/; s/ +//; s/conditions/conditions:/; s/Weather/Weather:/; s/Light/light/; s/Rain/rain/; s/Mist/mist/; s/Humidity/humidity:/; s/Temperature/Temperature:/; s/ C$/ C°/; s/ / /; s/Windchill .*\\n//; }; # Change the output order if ($#t == 5) { ($t[0], $t[1], $t[2], $t[3], $t[4], $t[5]) = ($t[5], $t[0], $t[1], $t[2], $t[3], $t[4]); } elsif ($#t == 4) { ($t[0], $t[1], $t[2], $t[3], $t[4]) = ($t[4], $t[0], $t[1], $t[2], $t[3]); } elsif ($#t == 3) { ($t[0], $t[1], $t[2], $t[3]) = ($t[3], $t[0], $t[1], $t[2]); } elsif ($#t == 2) { ($t[0], $t[1], $t[2]) = ($t[2], $t[0], $t[1]); } # Print the result print join "", @t;
после чего дообавить в GeekTool @ Mac OS X (Samurize @ Windows или Conky @ UNIX) что-то навроде следующего:
/путь/к/браузеру/lynx -dump -width 120 \\ http://weather.noaa.gov/weather/current/КОД-ВАШЕГО-ГОРОДА.html | perl \\ /путь/к/вышеозначенному/скрипту/w.pl