I’m a bit of a minimalist, and I don’t really like icons of fluffy clouds etc permanantly on my desktop. How many times a day do you need to be told what the weather is going to be fer cryin’ out loud?
Voider’s FVWM skills with his e-mail subject displayer gave me the necessary source to copy to make this all work in FVWM, because I’m not very good with FVWM. (Thanks Voider )
Firstly, here is a screenshot of the script in action:
You need three files, plus some amendments to your .fvwm2rc:
fvwm_get_weather.sh
[code]#!/bin/bash
fvwm_get_weather.sh
-------------------
Script to print out weather forecast in FVWM
HOME=/home/rob
WTMPDIR=${HOME}/tmp/weather
#make sure you have the correct WLINK variable for your home town
WLINK=UKXX0527_c.html
WURL=http://weather.yahoo.com/forecast/${WLINK}?force_units=1
DUMPFILE=${WTMPDIR}/weather_dump.txt
DATAFILE=${WTMPDIR}/weather.txt
lynx -accept_all_cookies -dump ${WURL} > ${DUMPFILE}
Make sure that lynx picked up the data correctly
#if
grep “Unable to connect to remote host” ${DUMPFILE} | wc -l
#erm I haven’t finished this bit yet
awk ‘/Currently:/, /Extended Forecast/’ ${DUMPFILE} | sed ‘s/° /°
/’> ${DATAFILE}
SEDFILE=${HOME}/bin/fvwm_weather.sed
SEDICONFILE=${HOME}/bin/fvwm_weather_icons.sed
DAY3=grep "Today Tomorrow" ${DATAFILE} | cut -d ' ' -f 6 | sed -f ${SEDFILE}
DAY4=grep "Today Tomorrow" ${DATAFILE} | cut -d ' ' -f 7 | sed -f ${SEDFILE}
DAY5=grep "Today Tomorrow" ${DATAFILE} | cut -d ' ' -f 8 | sed -f ${SEDFILE}
#head -6 ${DATAFILE} | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’
for no icons, unhash line above/hash line below, and vice-versa for icons
head -6 ${DATAFILE} | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’ | sed -f ${SEDICONFILE}
echo “+ “” Nop”
echo “+ Tomorrow”
#tail -17 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’
for no icons, unhash line above/hash line below, and vice-versa for icons
tail -17 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’ | sed -f ${SEDICONFILE}
echo “+ “” Nop”
echo “+ ${DAY3}”
#tail -13 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’
for no icons, unhash line above/hash line below, and vice-versa for icons
tail -13 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’ | sed -f ${SEDICONFILE}
echo “+ “” Nop”
echo “+ ${DAY4}”
#tail -9 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’
for no icons, unhash line above/hash line below, and vice-versa for icons
tail -9 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’ | sed -f ${SEDICONFILE}
echo “+ “” Nop”
echo “+ ${DAY5}”
#tail -5 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’
for no icons, unhash line above/hash line below, and vice-versa for icons
tail -5 ${DATAFILE} | head -4 | grep -v “sky:” | sed ‘s/^ */+ “/;s/$/”/’ | sed -f ${SEDICONFILE}
[/code]
(Make the necessary directory ~/tmp/weather or the script won’t work.)
fvwm_weather.sed
s/Sun/Sunday/g
s/Mon/Monday/g
s/Tue/Tuesday/g
s/Wed/Wednesday/g
s/Thu/Thursday/g
s/Fri/Friday/g
s/Sat/Saturday/g
fvwm_weather_icons.sed
s/"Mostly Cloudy"/\%wf_mostly_cloudy.png\%"Mostly Cloudy"/g
s/"Partly Cloudy"/\%wf_partly_cloudy.png\%"Partly Cloudy"/g
s/"Cloudy"/\%wf_cloudy.png\%"Cloudy"/g
s/"Mostly Sunny"/\%wf_mostly_sunny.png\%"Mostly Sunny"/g
s/"Sunny"/\%wf_sunny.png\%"Sunny"/g
s/"Rain"/\%wf_rain.png\%"Rain"/g
s/"Showers"/\%wf_showers.png\%"Showers"/g
s/"Light Rain"/\%wf_showers.png\%"Light Rain"/g
The fvwm_weather_icons.sed file is very incomplete. The weather here in Hemel hasn’t changed much recently, so I don’t know what the other different weather conditions are. I’ll add entries and icons as and when I come across different weather conditions, or upon request (give me a couple of weeks, I tend to get sidetracked).
You also need to amend your .fvwm2rc:
[code]AddToMenu MenuFvwmWeather
- DynamicPopupAction Function MenuFvwmWeather
DestroyFunc MenuFvwmWeather
AddToFunc MenuFvwmWeather
- I DestroyMenu recreate MenuFvwmWeather
- I AddToMenu MenuFvwmWeather
- I AddToMenu MenuFvwmWeather “weather” Title
- I PipeRead ‘/home/$USER/bin/fvwm_get_weather.sh’
[/code]
And in your .fvwm2rc menu
Test (x bash) + %weather_partly_cloudy.png%"weather forecast" Popup MenuFvwmWeather
(I have the above in a submenu.)
The icons are here: http://www.hyborian.demon.co.uk/fvwm/weather_icons.tar.bz2
I think that’s it. I hope you enjoy your weather forecasts on demand. It takes about 2 seconds to download and build the forecast (on my machine).
Rob