#!/bin/sh # # wxbg -- Get a surface weather map GIF and put it in the root window # # This shell script will get the current weather map GIF from a weather # map server via anonymous ftp and put it in the root window (background) on # your X terminal. The weather map GIF shows station # reports, fronts, isobars, and highs and lows. You'll need to have a # color display to show everything correctly, but if you only have a B&W # monitor you can still get a current B&W satellite image. European # users can easily modify the script to get satellite pictures from # METEOSAT-4 or METEOSAT-3 from Edinburgh. See below for details. # # Requirements: X and either xgifroot or xv # # If your machine supports personal crontabs then you can put # something like the following in your crontab to get the latest # weather map every hour: # # 20 * * * * $HOME/bin/wxbg # # The SA maps seem to be ready by around 15 past the hour, but I use 20 # minutes to be sure I don't miss it. The satellite pictures seem to # take longer -- change the 20 to 55. # # Command line options: -f forces the thing, even if it does not look # like you are running an X server. The -v flag is "verbose", it shows # you what it is doing. All other flags are passed to your XGIFROOT # program. Simply use the -display option to put the map on a machine # different from yours. # # Note for Europe: The Edinburgh server only updates their pictures once # a day, and they have a small machine which is easily overloaded, so # please DON'T poll them every hour like this. Just put wxbg in your # .xinitrc instead, or have cron update the picture once a day. # # Disclaimer: I hope you find this useful for getting the "big picture", # but don't forget to get a *real* weather briefing before you go flying. # I'm not responsible if you get yourself into trouble based on info # provided by wxbg. [And I wish I didn't feel I had to include this # disclaimer!] # # Eric Myers # Department of Physics, University of Michigan, Ann Arbor # @(#) $Id: wxbg,v 1.15 1999/07/26 19:35:15 myers Exp myers $ #======================================================================* # SELECT AN FTP SERVER: suitable servers come and go or change names # over the years, so you may need to tweak these settings: # The server vmd.cso.uiuc.edu was discontinued sometime at the end # of summer '93, and wuarchive.wustl.edu is overloaded. wmaps.aoc.nrao.edu # seems to be the best server as of 1/94, but you can change it here: #SERVER=wmaps.aoc.nrao.edu # NRAO stopped updating 31 Oct 97 #WXDIR=pub/wx # subdirectory where the maps are kept #PRE=sa # Surface Analysis and Radar (precip) #PRE=ci # North American satellite image (B&W) #FNAME="sfc_depict.gif" # leave blank to have it construct SA name # 20 Nov 97: Purdue seems the best bet SERVER=wxp.atms.purdue.edu # 26 Jul 1999: Purdue changed department name? SERVER=wxp.eas.purdue.edu WXDIR=web/surface # FNAME="sfc_map.gif" FNAME="sfc_depict.gif" # Alternate server: University of Edinburgh (Scotland) Meteorology Dept. # for satellite photos (Europe). I have not checked this in a long while! #SERVER=cumulus.met.ed.ac.uk #SERVER=129.215.168.19 # IP address, if your nameserver has problems #WXDIR=images/gifs # this is where the GIFs are kept #FNAME=uk.vis.gif # UK picture #FNAME=eur.vis.gif # Europe picture #FNAME=world.vis.gif # World picture #FNAME=norden.vis.gif # Scandinavia # SELECT A DISPLAY PROGRAM: # XGIFROOT is the program used to put a GIF in the root window. # xgifroot is faster, but if you don't have it then it can also be # done by an xv incantation. [You can get xgifroot via anonymous ftp # to lifshitz.ph.utexas.edu in /pub/graphics/src/xgifroot.tar.Z] # Unfortnately xgifroot reads GIF87 format but not GIF89 format. # # Change paths as appropriate, and use a full path name if you intend to # call wxbg from cron! #XGIFROOT=/usr/local/bin/xgifroot #XGIFROOT="/usr/local/bin/xv -max -root -quit " XGIFROOT="xv -max -root -quit " ######### End of Customization ######################################## # We need the ps command if we are to run as a cron job, to help # detect a running X server. But the ps command differs between BSD # and SYSV machines, so... if [ -d /usr/ucb ] # seems to be BSD then PSCMD="ps -x" else # maybe it's SYSV instead PSCMD="ps -ef" fi TMP=${TMP-"/usr/tmp"} # a temporary workplace # -- parse the command line arguments for flags FLAGS="" # flags will be passed to XGIFROOT command FORCE=N # don't be so forceful... while [ $# != 0 ] do case "$1" in -f) FORCE=Y ;; # force it even if X does not appear to be running -v) set -x ;; # verbose -d | -display) shift; DISPLAY=$1 ;; # get display name -*) FLAGS="$FLAGS $1" ;; *) PRE=$1 # command line argument sa or ci esac shift done # -- make sure an X server is running, or all is for naught. If DISPLAY # is set then assume that it's cool. Otherwise look for a server. (Add # your own server name to the list if you don't see it here, or use -f.) if [ "$DISPLAY" = "" -a "$FORCE" != "Y" ]; then X=`${PSCMD} | egrep "(xinit|xdm|dxsession|Xsgi|vuesession)" | grep -v grep` if [ -z "$X" ]; then echo "Error: Can't open display: $DISPLAY " ; exit 1 fi DISPLAY=${DISPLAY-":0"} # DISPLAY must be something fi # -- construct file name for current WX info, if FNAME not already specified if [ "$FNAME" = "" ]; then timestamp=`date -u '+%m%d%H'` # date & time as MMDDHH for file name FNAME=${PRE}${timestamp}.gif # e.g. SA071518.gif fi # -- go and get the GIF file from the server via anonymous ftp. # It will be called wxmap.gif in the $TMP directory, in case you # want to get at it some other way during the hour cd $TMP ftp -n $SERVER </dev/null 2>&1 user anonymous -$USER@`hostname` binary cd $WXDIR get $FNAME wxmap.gif quit EOF # -- only view the file if we got it OK (i.e. it's there and not empty) if [ -s wxmap.gif ]; then ${XGIFROOT} -display $DISPLAY $FLAGS wxmap.gif >/dev/null 2>&1 fi exit 0