Ubuntu wallpaper slideshow

The desktop background switcher included with Karmic Koala has a cool feature, a wallpaper slideshow that rotates images at a predetermined interval. However, getting it to cycle through your own set of images isn’t exactly user friendly. In order to get a sequence of images to display, the wallpaper picker must be supplied with an xml file with the following structure:





Where all paths are absolute. The xml file can be chosen as a wallpaper in the standard gnome wallpaper picker by going pressing add and choosing “All files” from the file filter drop down.

To make the process of creating these xml files a bit simpler, I made a python script that takes all images in a directory and generates an xml file for them. To use it, simply run it in the directory where the images are located and it will generate a file called “desktop.xml”. The default transition time is 1795 seconds (30 minutes). To change the switch time, supply the new interval in seconds as an argument:

./ubuWallGen 1200

You can get the latest version of the script using git:

git clone git://github.com/royvandewater/ubuWallGen.git

You can also download the script directly here


  1. Brilliant Roy!! … many thnx *smile*


  2. Ln 35 has an extra “>”

    • Good catch, I updated the script to fix this

  3. Great post!

    I’d suggest adding that you have to select desktop.xml as the selected wallpaper in “Change Desktop

  4. Great post!

    I’d suggest adding that you have to select desktop.xml as the selected wallpaper in “Change Desktop Background”, as I had to go to another site to find out how to use the XML file.


    • Thanks for the suggestion, I added in some instructions for that to the post.

  5. Great script!! Thanks

  6. You should have a look at Cortina, it has a FS watcher, so it updates whenever you add files. https://help.ubuntu.com/community/Cortina

  7. Tweaked your file to get images in alphanumeric order. Commented out one line, two lines added.

    “”” dirlist = os.listdir(os.getcwd()) “””

    dirlist = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(os.getcwd() + os.path.sep + d)])
    dirlist.extend(sorted([f for f in os.listdir(os.getcwd()) if os.path.isfile(os.getcwd() + os.path.sep + f)]))

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>