Lifehacker had a recent post on how to set your Ubuntu desktop background to a rendered picture of the earth, complete with accurate weather and sunlight. The lifehacker method involves downloading a new, fully-rendered image every four hours. This method is less than optimal. You can generate the same image yourself, using the same data, and update it continuously. Let me lay out how you should be automatically updating your Ubuntu background with an image of the earth, complete with accurate clouds.
The files on die.net are generated using xplanet. So far, I’ve used these directions without incident on Ubuntu 9.10, 10.04, and 10.10.
First, install the xplanet package, as well as the supplementary images package.
sudo apt-get install xplanet xplanet-images
Next, make a directory to for the rendered images and the satellite cloud image. I used ~/.backgrounds/.
mkdir ~/.backgrounds/
To get the cloud file and put it in the right place, you want to use wget.
wget -q -O ~/.backgrounds/clouds_2048.jpg http://xplanet.sourceforge.net/clouds/clouds_2048.jpg
This will grab a current cloud image and stick it in your ~/.backgrounds directory. To automate this, you should set up a cron job to do this every few hours. If you don’t know what it means to set up a cron job, install gnome-schedule.
sudo apt-get install gnome-schedule
Go to gnome schedule, Application >> System Tools >> Scheduled Tasks. Create a new scheduled task. Give it a description like “Update XPlanet Weather Map” and paste that wget command into the command box. For “Time & Date”, select Advanced. Put in a number between 0 and 59 in the minute box, to spread out the load. For the hour box, put in */4 to update the image once every four hours. Click apply, then run your task once from the main task list by pushing the gear button. This is the same procedure as the lifehacker article, except we’re downloading the cloud image from the gentleman who developed xplanet, instead of the pre-rendered image of the entire earth.
The next step is to create a configuration file for xplanet. Mine is .xplanet and it is in my home directory. It looks like this. You will need to change the <YOUR USERNAME> part.
[earth]
cloud_map=/home/<YOUR USERNAME>/.backgrounds/clouds_2048.jpg
image=/usr/share/xplanet/images/earth.jpg
night_map=/usr/share/xplanet/images/night.jpg
In order to find out how big of a picture xplanet should render, you need to know how big your screen is. You can find this by going to System>>Prefernences>>Display. My display happens to be 1440x900. The method we’re using to render the map does a poor job of rendering the poles, so make your picture a little bit taller. I used 1440x980. We’ll then center the picture so that the poles get cut off.
Next up is setting up xplanet so it will run on startup. Go to System >> Preferences >> Startup Applications. Click Add. Name it xplanet, and give it the following command, replacing the geometry with the numbers appropriate for your screen.
xplanet -config .xplanet -hibernate 120 -output .backgrounds/earth.jpg -geometry 1440x980 -projection mercator
Click save, log out, and log back in. Open up a terminal, and make sure that xplanet is running.
ps auwwwx|grep xplanet
There should be output that looks something like this.
n 1672 0.2 0.3 84680 14132 ? S Jan17 0:24 xplanet -config .xplanet -hibernate 120 -output .backgrounds/earth.jpg -geometry 1280x1000 -projection mercator
The only step that is left is to point gnome to the updating image file. Right click on your desktop and select Change Desktop Background. Click Add. Type .backgrounds at the top into the location bar and hit enter. Click on earth.jpg, and open it. Select a style of centered, and close the appearance preferences. You should now have an automatically updating, continuously rendered, accurate map of the world as your desktop background.
For bonus points, you can find out the longitude of where you live and put that at the center of the map. I found out my longitude and added a “-longitude -81” onto the end of my xplanet command line. This made the xplanet command above look like this.
xplanet -config .xplanet -hibernate 120 -output .backgrounds/earth.jpg -geometry 1440x980 -projection mercator -longitude -81
Have fun, and let me know if I made any mistakes or if anything needs clarification.
Lots of great ideas in the comments below, please give them a quick skim if you are having any problems or want to find some other interesting possibilities. I’m currently pondering updating my “daytime” image based on the month of the year. Cool stuff.
I’ve also added a “-q” to the wget command line. Cron is a great way to run regularly occurring scripts. We use it here to run wget on a regular basis, downloading new cloud files. Cron will email you the output of any command it runs. Without the -q, wget spits out all sorts of helpful information. It will continue to spit out that helpful information when run by cron, and you will end up with an email every few hours letting you know all about it. The -q turns that off.
I pointed a super-fancy algorithm at this to try to automatically find some related posts, and the best it could do was Creating a Smoke Animation with Javascript and HTML Canvas, Online Business: Choosing a Domain Name, and Online Business: DNS.
I have a handy list of all posts available on the blog, and you can find more information about me, and how to contact me, on my front page.