five day weather forecast

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 :smiley: )

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

Hey man, It’s cool, I test it imediatly…

that work great, I change little things in the variables… but it’s great…

Of course I have a question, where did you find the icons ?? In QNX ?? I haven’t same weather…

Hi Bibi,

I created the icons myself, although I used the QNX weather_partly_cloudy.png icon as a template. I’m still not sure if it’s better with or without the icons …

:confused:

Regards,

Rob

ok, I’ m going to add the icons…

I like the icons, because I can see weather a little bit faster than if I must read it…

Looks very nice :slight_smile:

here is another (simpler, no Icons) solution, it uses the german “videotext”-pages, that are available in the web, too.

You can run it in a Xterm without title/borders sent to the background :slight_smile:

Save as “vt.sh”, make it executable (chmod755 vt.sh), and run it with page 173:
./vt.sh 173

It will update every hour (3600 seconds).

#!/bin/sh

PAGE=$1

wget -q http://www.ard-text.de/videotext/index.html?tafel=$PAGE -O tafel.htm

echo "<html><head></head><body>">neu.htm
cat tafel.htm | grep "<font class">>neu.htm
echo "</body></html>">>neu.htm

lynx -nolist -dump neu.htm |grep -v "<<">test.txt

clear
cat test.txt

sleep 3600
$0 $1

Mark

Hi Mu, that’s interesting. Mine also started as a shell script for running in a term:

get_weather.sh

[code]#! /bin/bash

get_weather.sh

--------------

Script to print out weather forecast

HOME=/home/rob
WTMPDIR=${HOME}/tmp/weather

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

awk ‘/Currently:/, /Extended Forecast/’ ${DUMPFILE} | sed ‘s/° /°
/’> ${DATAFILE}

DAY3=grep "Today Tomorrow" ${DATAFILE} | cut -d ' ' -f 6
DAY4=grep "Today Tomorrow" ${DATAFILE} | cut -d ' ' -f 7
DAY5=grep "Today Tomorrow" ${DATAFILE} | cut -d ' ' -f 8

echo “Weather”
#echo “Weather”
head -6 ${DATAFILE} | sed ‘s/^ *//’

echo “”
echo “Tomorrow”
tail -17 ${DATAFILE} | head -4 | sed ‘s/^ *//’

echo “”
echo “${DAY3}”
tail -13 ${DATAFILE} | head -4 | sed ‘s/^ *//’

echo “”
echo “${DAY4}”
tail -9 ${DATAFILE} | head -4 | sed ‘s/^ *//’

echo “”
echo “${DAY5}”
tail -5 ${DATAFILE} | head -4 | sed ‘s/^ *//’
[/code]

Although the fvwm_get_weather.sh has been refined a bit since then …

:slight_smile:

Rob

just a remark, in fvwm_weather.sh you define HOME=/home/rob but later you use /home/rob indead of ${HOME}

most people will notice this I guess, but you might want to change that.

Thanks for that. I have edited the script in the first post. Unfortunately, it seems to have buggered up the thumbnail of the screenshot and the link to the icons. Ho hum.

it seems that it tried to make an url of it. I guess removing the url-tags will solve that.

edit: hmm, that didn’t solve it. maybe the forum upgrade is the problem