Create a Custom Transitioning Background for Your Gnome 2.28 Desktop

While test-driving the new Gnome 2.28 desktop, I was surprised to see that among the default backgrounds, there was a "Cosmos" slide-show of several cosmic pictures of space that regularly transition on your desktop. While I had used this feature in the past when using KDE, I was not aware of how to create my own slide-show backgrounds in Gnome. By examining how the Cosmos slide-show works, I figured out how to create my own custom slide-show backgrounds. Read on and find out to create your own custom desktop background.

Creating a Custom XML File for Your Backgrounds

Gnome uses an XML file to contain the configuration information necessary to run the backgrounds as a slide-show. The "Cosmos" XML file can be found at /usr/share/backgrounds/cosmos/background-1.xml and contains all of the information that Gnome requires.

Here is what it looks like:

<background>
  <starttime>
    <year>2009</year>
    <month>08</month>
    <day>04</day>
    <hour>00</hour>
    <minute>00</minute>
    <second>00</second>
  </starttime>
<!-- This animation will start at midnight. -->
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/cloud.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/cloud.jpg</from>
    <to>/usr/share/backgrounds/cosmos/comet.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/comet.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/comet.jpg</from>
    <to>/usr/share/backgrounds/cosmos/earth-horizon.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/earth-horizon.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/earth-horizon.jpg</from>
    <to>/usr/share/backgrounds/cosmos/blue-marble-west.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/blue-marble-west.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/blue-marble-west.jpg</from>
    <to>/usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg</from>
    <to>/usr/share/backgrounds/cosmos/helix-nebula.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/helix-nebula.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/helix-nebula.jpg</from>
    <to>/usr/share/backgrounds/cosmos/jupiter.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/jupiter.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/jupiter.jpg</from>
    <to>/usr/share/backgrounds/cosmos/sombrero.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/sombrero.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/sombrero.jpg</from>
    <to>/usr/share/backgrounds/cosmos/whirlpool.jpg</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/usr/share/backgrounds/cosmos/whirlpool.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/usr/share/backgrounds/cosmos/whirlpool.jpg</from>
    <to>/usr/share/backgrounds/cosmos/cloud.jpg</to>
  </transition>
</background>

The duration is listed in seconds (the <duration> tag), so the 1795.0 specified for an image (the <static> tag) would be 29 minutes and 55 seconds. During a five second transition (the <transition> tag), the previous image changes to the current image. When this image has been shown for 1795 seconds, it then transitions to the next file. In the "Cosmos" XML file, the last file transitions back to the first file in the listing. I followed this convention in my XML template file, which you can use to create your own custom slide-show listing:

<!-- Template created by Ross Larson for linuxjournal.com -->
<background>
  <starttime>
    <hour>0</hour>
    <minute>00</minute>
    <second>01</second>
  </starttime>
<!-- this creates an arbitrary start time of 12 am -->
  <static>
    <duration>855.0</duration>
    <file>/path/to/wallpaper_number_one.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/path/to/wallpaper_number_one.jpg</from>
    <to>/path/to/wallpaper_number_two.jpg</to>
  </transition>
  <static>
    <duration>855.0</duration>
    <file>/path/to/wallpaper_number_two.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/path/to/wallpaper_number_two.jpg</from>
    <to>/path/to/wallpaper_number_three.jpg</to>
  </transition>
  <static>
    <duration>855.0</duration>
    <file>/path/to/wallpaper_number_three.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/path/to/wallpaper_number_three.jpg</from>
    <to>/path/to/wallpaper_number_four.jpg</to>
  </transition>
  <static>
    <duration>855.0</duration>
    <file>/path/to/wallpaper_number_four.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/path/to/wallpaper_number_four.jpg</from>
    <to>/path/to/wallpaper_number_five.jpg</to>
  </transition>
  <static>
    <duration>855.0</duration>
    <file>/path/to/wallpaper_number_five.jpg</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/path/to/wallpaper_number_five.jpg</from>
    <to>/path/to/wallpaper_number_one.jpg</to>
  </transition>
</background>

Since I have a shorter attention span than the Gnome developer who created the original XML, I created a default duration of 855.0 + 5.0 seconds, or 15 minutes per image including transition. If you wish to add additional images, or remove images, from your XML, simply add, or remove, the following:

<static>
  <duration>855.0</duration>
  <file>/path/to/wallpaper_you_want_to_add.jpg</file>
</static>
<transition>
  <duration>5.0</duration>
  <from>/path/to/wallpaper_you_want_to_add.jpg</from>
  <to>/path/to/next_wallpaper.jpg</to>
</transition>

A rule of thumb for parsing the XML file is that you will see each image path mentioned three times:

  • Once to transition from the previous image to the current image.
  • Once to indicate the duration of the current image.
  • Once to transition from the current image to the next image.
Notes
  • Rename the XML to any name you wish, as long as you keep the .xml extension.
  • The path to the images does not have to point to /usr/share/backgrounds, but keep in mind that if you change distros or migrate from one computer to another, the XML will not work if the images are in a different path than the one indicated in your XML file.
  • Make sure to transition back to the first image when entering information about the last image in your desktop slide-show.
  • I recommend using GVIM to edit your XML file, as I was able to make extensive use of the "Find and Replace" feature to update file names and durations. If you're awesome like Kyle Rankin and live at the command line, feel free to use the old school vim text commands, as well.
Selecting the Completed XML File in GNOME

To activate your new background:

  • Right-click on your desktop to select "Change Desktop Background"

    lj1.jpg
  • Choose "Add" from the background appearance preferences window.

    lj2.jpg
  • Select the "All Files" filter to show the custom XML file that you have created.

    lj3.jpg
  • Choose your custom XML file and select "Open". (Here, my XML file is named "dualies.xml")

    lj4.jpg
  • Select your new desktop background slide-show, and admire the results.

    lj5.jpg

This process has been tested in Ubuntu 9.10 and Fedora 12, though I assume that it will work in any environment that is capable of running Gnome 2.28

Enjoy!

Load Disqus comments