The “KARR” part of the URL is for the Aurora airport station. The -width 100 option keeps lynx from wrapping some of the longer lines in the output. The -dump option causes lynx to send its interpretation of the page to STDOUT instead of opening in an interactive mode. The text dump of the page is accomplished with this command: I get the current weather by feeding the airport station’s URL to lynx. To do this, I went to and drilled down through their search system until I found the page for the Aurora, Illinois airport station-reasonably close to my home in Naperville. Then I found the NOAA page for a weather station close to me. I used MacPorts, which put the lynx binary in /opt/local/bin/. I made some adaptations, which I describe below.įirst, I installed lynx, the venerable console browser. This writeup (which has lots of other GeekTool hints and examples) showed me how to scrape the info I wanted off a NOAA page. So today I went looking for another way to get the weather on my desktop. One thing I didn’t like about it was the size and readability of the text in the picture the temperature-what I wanted most of the time-was kind of lost in all the other information. It worked fine, and I wrote a little description of how I did it back in July of last year. The picture was actually mostly text, giving the current conditions for my hometown. I used to use GeekTool to put a little picture from Accuweather in the lower left corner of my desktop. Now my Desktop looks like this.Next post Previous post More Desktop weather with GeekTool The change is the optional hyphen ( -?) before the digit. The temperature is always on theġ7: # second line, so exchange it with the last line.Ģ0: # Sometimes there's a windchill line, and sometimes there isn't.Ģ1: # Add a blank line to the front of the array if there isn't.Ģ4: # Print the lines of interest in the order I want.Ģ5: print join "", 7 has the new regular expression. This is what the noaanow script looks like now: 1: #!/usr/bin/perlģ: # Grab all the lines and put in an array.Ħ: # Keep only certain lines for the current conditions.ħ: = grep /^ (Temperature -?\d|Wind|Relative)/, # Erase the leading spaces and parenthetical (metric) values.ġ5: # I want the temperature line to print on the bottom to make itġ6: # easy to see on the desktop. I couldn’t believe I hadn’t run into this bug earlier maybe I just wasn’t paying attention on below-zero days before today. So the regular expression didn’t collect the temperature line. The problem was that today’s temperature didn’t start with a digit( \d), it started with a minus sign (actually a hyphen). Many lines in the data start with the word “Temperature,” but only the line with the current temperature is immediately followed by a number, hence the Temperature \d portion of the regular expression. Ob KARR 181452Z 00000KT 4SM BR CLR M18/M18 A3034 RMK AO2 SLP291 T11781183 51011Īnd here’s the line in the Perl script that extracts the data I want = grep /^ (Temperature \d|Wind|Relative)/, is the list of all the lines in the data. Pressure tendency 0.03 inches (1.1 hPa) higher than three hours ago Here’s chunk of the output that has the current conditions Conditions at In the Terminal, I saw what the problem was. I first thought that NOAA had changed the format of the data, which would screw up my extraction script, but after running /opt/local/bin/lynx -dump -width 100 This gets a big chunk of data from the local NOAA weather station and dumps it to a Perl script that extracts just the parts I want to display. Why was the temperature missing? The GeekTool shell command that controls the display is this command /opt/local/bin/lynx -dump -width 100 | /Users/drang/bin/noaanow Here’s what the lower left corner of my Desktop looked like. Today I noticed that my GeekTool weather information was goofed up. Next post Previous post GeekTool desktop weather fix
0 Comments
Leave a Reply. |