Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create an auto-updating desktop image Desktop
This hint will make your desktop update automatically with any web image you like; the example uses the latest weather maps.
  1. Create the directory ~/Desktop/Weather.

  2. Open System preferences, select Desktop. Under the collections popup list, navigate to the Weather folder. Select Center for the image position, then set the "Change picture" pop-up to every five minutes.

  3. Create this perl script:
    #!/usr/bin/perl
    while(1){
      # download radar image (this command works for any URL)
      # NOTE: Enter the next three lines as ONE line -- do not
      #       add any spaces when combining the lines (ie no
      #       spaces after the slashes!).
      system ("curl http://weather.noaa.gov/radar/images/
        DS.p19r0/SI.klwx/latest.gif >~/Desktop/Weather/
        latest.gif");
      sleep(300);
    }
    
    Don't forget to use UNIX line breaks and after you save it, open the Terminal, navigate to the directory the script resides in (I used ~/Desktop/Weather), and do chmod +x getweather to make the script executable.

  4. Launch the script by typing ./getweather &
You're done.

The perl script fetches an image from the NOAA doppler radar site (For the Washington, D.C. area in this case, but choose whatever you like). The script then sleeps for 5 minutes (300 seconds) and then fetches the image again, overwriting the original. At the same time, the Desktop sytem preferences updates the desktop every 5 minutes, which will always keep the image current on your screen. You can use other images; try any web cam you like, of course!
    •    
  • Currently 3.00 / 5
  You rated: 4 / 5 (5 votes cast)
 
[10,087 views]  

Create an auto-updating desktop image | 12 comments | Create New Account
Click here to return to the 'Create an auto-updating desktop image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create an auto-updating desktop image
Authored by: Harold on Jul 14, '03 10:55:16AM
On a related note I've created a script that downloads the latest Astronomy Picture of the Day and sets it as your desktop background using PERL, CRON, curl and OSAscript (all included in OS X). You can get it here aong with instructions:
http://www.haroldbakker.com/personal/apod.php

OS X continues to rock.

---
NIL ANXIETAS
http://www.haroldbakker.com/
http://www.virtualpetrock.nl/

[ Reply to This | # ]

Create an auto-updating desktop image
Authored by: bluehz on Jul 14, '03 02:02:42PM

And where are the scripts to download. Web page says...

"Download the stuffed archive using the link at the bottom of this page."

I looked all over that page and never found any "stuffed archive" or anything else to download. Using Safari 1.0.



[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: zacht on Jul 14, '03 11:21:41AM

This hint is Totally Sweet. Except... what if the download fails? Curl is supposed to be very sophisticated (or so i've heard), but will the perl script and the Desktop picture thing be OK? Will the desktop picture stay the same or go blank? Will there be lots of network attempts? (Or system log "spamming"?)

The reason I ask is that my laptop is often not connected to a network and I'd hate to have my computer freeze up or "stutter" every five minutes... And if it goes into "retry every thirty seconds" mode, or something like that, it would be horrible.

I guess I could try it and find out. But hopefully someone can reassure me?...

zach



[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: Mikey-San on Jul 14, '03 03:54:03PM

Well, curl will not stop your machine from doing anything. The download will just fail, a la reachinga 404 error with a Web browser.



[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: robJ on Jul 14, '03 11:50:25AM
WebDesktop, developed by Panic co-founder and programmer Steven Frank, might be of interest. It layers a web browser over your Mac OS X desktop by using WebKit, Apple's HTML rendering engine from Safari. It offers an automatic refresh interval.

[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: merlyn on Jul 14, '03 12:11:30PM
This is really an example where Perl is overkill. Just a shell script would have been fine:

#!/bin/sh
while
   curl -O ~/Desktop/Weather/latest.gif http://weather.noaa.gov/radar/images/DS.p19r0/SI.klwx/latest.gif
do
  sleep 300
done


[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: bluehz on Jul 14, '03 12:43:27PM
Why even bother with the sleep. Just create a simple shell script
#!/bin/sh
# Filename: weather-desktop

cd ~/Documents/desktop-pict/
curl http://www.srh.noaa.gov/radar/images/DS.p19r0/SI.ktbw/latest.gif > radar.gif
and set it up as a crontab task...
*/5 * * * * ~/bin/weather-desktop
and if you want to get fancy and have ImageMagick installed you can do all sorts of manipulation before displaying the desktop. A simple example.... the size of downloaded image is way to big for me and sits smack in the center of the desktop... I would like the image reduced and down in teh lower left corner instead....hmmm
#!/bin/sh
# Filename: weather-desktop

# original desktop pict or solid color the same size as desktop
origd=~/Documents/desktop.pict   # change this....
wdir=~/Documents/desktop-pict/   # and this.... location of your download images

# change into working dir where you download images, and point
# Desktop Pref pane too
cd $wdir

# download the image as usual
curl http://www.srh.noaa.gov/radar/images/DS.p19r0/SI.ktbw/latest.gif > radar.gif

# combine the original desktop (in this case mine is a solid blue)
# with the newly downloaded radar image, scaling to a width of
# 300px and locating at position 31px from left and 550px from top
composite -compose over -geometry 300x+31+550 radar.gif $origd latest.gif


[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: FourtySeven on Jul 14, '03 01:28:20PM

I am new to Unix so there is probably a better way to do this but, using this script I've been able to creat moving weather maps on my desktop. First you need to find your favorite weather site (I use www.weather.com). Navigate to a moving animation of your local map. Now you need to find the names of the images of the animation (it's usually only about 5 frames). Tell the curl script to download all 5 images and put them into the weather folder. Remember to specify a different name for each one.

Now to make it look animated you need to go into ~/Library/Preferences/com.apple.desktop.plist Change the number between the <real> tags to 1. That should update it fast enough to have a realistic animation.
<key>ChangeTime</key>
<real>someNumber</real>

Here's a copy of my script (which could probably be optimized/simplified a lot more).


#!/usr/bin/perl
while(1){
# download radar image (this command works for any URL)
# NOTE: Enter the next three lines as ONE line -- do not
# add any spaces when combining the lines (ie no
# spaces after the slashes!).
system ("curl http://image.weather.com/looper/archive/us_dca_closeradar_large_usen/1L.jpg?1058195945122 >~/Weather/latest1.jpg");
system ("curl http://image.weather.com/looper/archive/us_dca_closeradar_large_usen/2L.jpg?1058195945122 >~/Weather/latest2.jpg");
system ("curl http://image.weather.com/looper/archive/us_dca_closeradar_large_usen/3L.jpg?1058195945122 >~/Weather/latest3.jpg");
system ("curl http://image.weather.com/looper/archive/us_dca_closeradar_large_usen/4L.jpg?1058195945122 >~/Weather/latest4.jpg");
system ("curl http://image.weather.com/looper/archive/us_dca_closeradar_large_usen/5L.jpg?1058195945122 >~/Weather/latest5.jpg");
sleep(1800);
}



[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: MacMuse26 on Jul 24, '03 06:29:51PM

Can anyone else get the faster animation to work as described above? Just seems to ignore a value of '1'. I'm at 10.2.6



[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: n9yty on Jul 14, '03 06:30:10PM

Rather than have a perl or even a shell script that is just sitting in limbo, why don't you use cron?

I'd create a cron entry (use CronniX if you'd like to make it easier) that just ran curl every five minutes. Or, if you want to go the extra step, have cron run your perl or shell script where you can do error checking / image recover / etc...



[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: calroth on Jul 15, '03 04:52:01AM

Change desktop picture without Finder restart - rather than using the Desktop preference pane, you can use AppleScript wrapped in a shell script to do the same task in a neater way.

This is also a near-duplicate of New auto-change desktop picture script.

So, with this tip, and the tip above about using cron to schedule updates, and the tip above about using sh instead of perl, we've completely replaced all parts of the hint on this page (and, in my opinion, made it much better).

[ Reply to This | # ]
Create an auto-updating desktop image
Authored by: WildWest on Jul 15, '03 08:31:37PM

i tried this but was unable to get it to work. One reason is that I am completely clueless when it comes to unix, but I thought this would be a good way to start diggin in.

Also, I tried with a different webcam, the New York cam from <http://www.earthcam.com/usa/newyork/timessquare/>. That could also be the reson it didn't work.

Can anyone maybe give me a hand I think it would be pretty cool if I could get this to work. thanks
-john



[ Reply to This | # ]