Android and Linux

Monday, August 2, 2010

Weather

I've always found it simpler and faster to pull weather information from weather.gov than to use a weather program. I normally use lynx to dump the page on a computer, but it's not available for Android, so I made these using wget. These small scripts can get weather information in about half a second, which is faster than opening a weather app and navigating to the information you want.

To use them, first go to http://mobile.weather.gov, type in your zip code, then it will take you to a page with the following links:

Detailed 7-day Forecast
Your Local Radar
Current Conditions
Satellite Image
Hazardous Weather
Area Forecast Discussion

Copy the links for "Detailed 7-day Forecast" and "Current Conditions" to use in these commands.

wx-forecast:
wget -q "LINK" -O - | sed -e 's/<br><br>/\n\n/g' -e 's#<[^>]*>##g
Copy "wx-forecast" to your clipboard with this QR code, and don't forget to edit the LINK for your location:


wx-current:
wget -q "LINK" -O - | tr -d '\n' | sed -e 's/<br>/\n/g' -e 's/&deg;//g' -e 's#<[^>]*>##g' | grep -v -E '(Current|Service|Lat:)'
Copy "wx-current" to your clipboard with this QR code, and don't forget to edit the LINK for your location:


If you want to run these from GScript shortcuts, GScript has a bug that makes text unscrollable over a certain number of lines and the forecast puts out too much information, so you only see the last few lines which are the last few days of the 7-day forecast. I found that running wx-forecast | grep -A 9 "Last Update" should gives you 4 lines of forecast info. Since days are split up between day and night, this will give you the forecast for approximately the next 36 hours, which is pretty much as far out as a forecast is reliable anyway.

Followers