Sunday, 21 February 2010

Earth Wallpaper

A few weeks ago I stumbled across this and it worked ok for a little while but then it stopped working properly. It would only update when logging on or restarting. Frustrated I looked through the comments to see if anyone else had had similar problems. One helpful commenter (john72carter) put the following:
the script looks overly complex.
why not have a basic script like below called by crontab every 15min.
btw you need to reflesh the background (hence the last line of the script) otherwise whats in ~/.gnome2 doesn't get displayed.
you might also want to add a call to the script below at startup rather than waiting for the next cron run to update the stale image

#!/bin/bash
wget http://static.die.net/earth/mercator/1600.jpg -O ~/.gnome2/mercator.jpg
gconftool-2 --type string --set /desktop/gnome/background/picture_filename ~/.gnome2/mercator.jpg


So this is what I set out to do.

First I created a new script called "earthwallpaper.sh" with the following in:

#!/bin/bash
wget http://static.die.net/earth/mercator/1600.jpg -O ~/.gnome2/mercator.jpg
gconftool-2 --type string --set /desktop/gnome/background/picture_filename ~/.gnome2/mercator.jpg

Then I had to find out how crontab works. Put simply it's a method by which scripts can be performed hourly, daily, weekly or monthly just by putting the script in the right folder.
The folders are stored in the /etc directory and are: cron.hourly, cron.daily...you get the idea.
I put my script in the hourly folder.

So far so good everything seems to be working a-ok! Big thanks to john72carter, a much simpler way of achieving the same effect.

The Mercator project is pretty interesting. Aside from mapping the current daylight hours around the world it also updates the cloud patterns every 3 hours from weather satellite data.

No comments:

Post a Comment