Background with xplanet and XFCE
Posted by Jason on September 1, 2008
One thing I finally got working was the ability to show background image of the earth on my desktop that would update during the day.
It’s not too hard, and is a pretty nifty background image. Here’s how I did it:
1. You need install xplanet – also, check out the Gallery there so you can get an idea of what sort of image you want.
2. Create a directory to stick in all the image and config files. I am using ~/.xplanet.
3. You don’t have to do this, but I wanted to get some better image files to work with than the ones that come with the stock program, you can search these out on the internets, but here are the ones I use:
Base map: Choose one from the NASA Visible Earth series. Here is the specific one I am currently using (a 2.1MB jpg).
Night map: I like Don Edwards’ selections, available from The Celestial Motherlode. Here is a zip containing the specific one I am currently using.
Bump map: A bump map helps simulate the height of mountains and stuff. Again, from NASA, here is the specific one I am currently using.
Specular map: A specular map helps simulate the reflection of the sun. Again, Don Edwards has a nice selection at The Celestial Motherlode. Here is a zip containing the specific one I am currently using.
Cloud map: You can use a script to gather up a quasi-real time cloud map. Here is the information direct from the xplanet site (and here is the Python script). I have slightly edited the script to grab the higher quality files and save them as ~/.xplanet/clouds_4096.jpg – you don’t have to do this, but if you want to here is my edit (pay attention to the directory):
#
# download_clouds.py ver. 1.1
#
# Download coulds map for xplanet from a random mirror, optionally
# save the one to archive directory.
#
# Usage:
# python download_clouds.py - to save the output as clouds_2048.jpg
# python download_coulds.py output.jpg - to save the output as output.jpg
#
# (C) 2004 Michal Pasternak <michal@pasternak.w.lub.pl>
#
# This file is in public domain.
# user-tunable parameters:
# how often to download the image?
maxDownloadFrequencyHours = 3
# how many times to retry if download fails (each time tries using a
# different mirror)
maxRetries = 3
# default filename of the output file (in current directory). You can
# specify it on the command line
defaultOutputFile = "/home/jason/.xplanet/clouds_4096.jpg"
# archive dir - where to save old files?
archiveDir = None # "/usr/public/cloudsArchive"
# The list of mirrors. Add new ones here.
mirrors = [ "http://xplanet.sourceforge.net/clouds/clouds_4096.jpg",
"http://www.narrabri.atnf.csiro.au/operations/NASA/clouds_4096.jpg",
"http://www.ruwenzori.net/earth/clouds_4096.jpg",
"http://userpage.fu-berlin.de/~jml/clouds_4096.jpg" ]
# end of user-tunable parameters
import random, urllib, sys, stat, time, os
# set output file name
try:
outputFile = sys.argv[1]
except:
outputFile = defaultOutputFile
pass
# check if the file exists and is old enough to overwrite
try:
s = os.stat(outputFile)
mtime = s[stat.ST_MTIME]
fs = s[stat.ST_SIZE]
found = True
except:
mtime = 0
fs = 0
found = False
pass
if time.time() - mtime < maxDownloadFrequencyHours * 3600 and fs > 400000:
sys.stderr.write("File is already up to date!\n")
sys.exit(0)
else:
if found and archiveDir is not None:
# archivize old file
import shutil
archName = os.path.join(archiveDir, time.strftime("%Y-%m-%d_%H-%I") + "_" + os.path.basename(outputFile))
sys.stderr.write("Archivizing old file to %s...\n" % archName)
shutil.move(outputFile, archName)
pass
pass
# ok, download:
for a in range(maxRetries):
try:
url = mirrors [ random.randint(0, len(mirrors)-1) ]
sys.stderr.write("Using %s\nDownloading...\n" % url)
urllib.urlretrieve(url, outputFile)
break
except:
pass
pass
That is all the map images you will need. You can of course search around for different maps if you like. You can also use a static cloud map if you like instead of downloading one as well.
If you compare this to the stock maps, I think you’ll notice the difference.
4. Now, set up the configuration file for xplanet to reference. I created this file as ~/.xplanet/xplanet-right-monitor.cfg:
[earth] map=/home/jason/.xplanet/world.topo.bathy.200408.3x5400x2700.jpg bump_map=/home/jason/.xplanet/srtm_ramp2.world.5400x2700.jpg night_map=/home/jason/.xplanet/land_ocean_ice_lights_aurora_4k.png cloud_map=/home/jason/.xplanet/clouds_4096.jpg specular_map=/home/jason/.xplanet/8kEarthSpecular.jpg
5. Now, there are 3 things that need to happen:
5a. Download the cloud map:
python /home/jason/.xplanet/download-clouds-4096.p
5b. Run xplanet:
xplanet -config /home/jason/.xplanet/xplanet-right-monitor-config --num_times 1 --output /home/jason/.xplanet/xplanet-right.jpg --latitude +26.38 --longitude +127.72 --radius 60 --geometry 1920x1200
Note that we specify where to find the config file (–config), where to place the output file (–output), the size of the image to generate (–geometry). Also, you will want to change the –latitude and –longitude to something interesting for you!
5c. Refresh the XFCE desktop image:
killall -USR1 xfdesktop
As it turns out, it’s pretty tricky to call xfdesktop –reload from a cron job, so we will go this route instead. Lots of applications use SIGUSR1 to reload settings (conky does the same thing).
5d. Stick all these things up in a little script. I used ~/.xplanet/xplanet-right-monitor.sh:
python /home/jason/.xplanet/download-clouds-4096.py > /dev/null && xplanet --config /home/jason/.xplanet/xplanet-right-monitor-config --num_times 1 --output /home/jason/.xplanet/xplanet-right.jpg --latitude +26.38 --longitude +127.72 --radius 60 --geometry 1920x1200 > /dev/null && killall -USR1 xfdesktop
6. Set XFCE to use the appropriate image. In my case, this is just a matter of Xfce Settings Manager > Desktop > Appearance > Screen 1 > Image > File and using: /home/jason/.xplanet/xplanet-right.jpg
Just change to what is appropriate.
You might want to run the script once before making this change so that the .jpg actually exists to point to.
7. Finally, set up a cron job to do the deed automatically. For myself I set it to update on the hour. Use crontab -e to edit your cron jobs and use something like:
@hourly /home/jason/.xplanet/xplanet-right-monitor.sh
And that’s it! Marvel at the results:
- Xplanet (later in day)
- Xplanet Background
- Xplanet (without maps)
The last there is without using all those maps we downloaded. That way you can decide if getting the maps is worth it for you or not!
9 Responses to “Background with xplanet and XFCE”
Sorry, the comment form is closed at this time.




churchyard said
Hi, I cannot see any licence of this post/whole blog. So I just want to ask if I can translate this article to Czech (with link to this site in beginning and your name if you want) and publish it on my Xfce blog (URL filled into website input).
ushimitsudoki said
churchyard,
Yes please, feel free to translate the article. Since you brought this up I have decided to use the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License for my blog.
I’m glad you thing it is worth translating!
churchyard said
Thanks. Sure it is.
~churchy » Xplanet: planeta na ploše said
[...] na svém blogu vydal návod na zprovoznění xplanet v XFCE. Dovolil mi ho přeložit a jako obvykle přidávám pár svých postřehů. Xplanet umožňuje [...]
churchyard said
OK, translated… http://neverhood.etomite.cz/~churchy/257-xplanet-planeta-na-plose
David said
I love it! Thank you for the walkthrough on how to set that up. One big favor, please: can I get a copy of your conky.conf to play with because I struggle to get that layout for myself. ak.prentice AT gmail.com
Andrew said
Hello – I’ve been playing around with xplanet myself the last few days. With the right configuration, this program gives beautiful results.
Some observations:
The python download script has a fault, not really a bug: a file size over 400 000 qualifies for a re-download, but the cloud maps are often smaller than that. I ended up leeching a bunch of files in rapid succession during my setup until i figured this out. Just replace 400 000 with a smaller number of bytes, say 200000.
The visible earth images are available in three forms: plain, with ocean depth information, and with topo+ocean depth. If you are going to add a bump map, clouds, specular highlights, etc. I’d go with the “plain” version which amounts to a photo of the earth’s surface. The bump map will add shadows and the oceans will appear flat dark blue – the result is a strikingly realistic earth. Add –projection mercator for a bit of variety, or if your belief system doesn’t admit a spherical eath.
The NASA blue marble next generation images are available in 12 versions, one for each month. You can make a script to change the image each month so you can see the snow advance and the tropics turn green over the next year.
Well positioned with the lat and long parameters, you can watch the light disappear over the horizon and the city lights come on (on your globe) just as the sun sets out your office window… I love this thing!
-Andrew
Bookmarks about Cron said
[...] – bookmarked by 5 members originally found by mesmoland on 2008-10-02 Background with xplanet and XFCE http://meandubuntu.wordpress.com/2008/09/01/background-with-xplanet-and-xfce/ – bookmarked by 2 [...]
Richard said
xfce 4.8 doesn’t work with killall -USR1 xfdesktop
xfdesktop –reload however works like a charm