Desktop wallpaper slideshow in Ubuntu 11.10
For no other reason than “it looks nice” (and showing snooty Windows users that we can do anything they can do – and in hundreds of different ways ), I decided to set up my desktop wallpaper to change at different times throughout the day.
There are programs in the repositories which will do this (notably CREBS and wallch), but I like to keep things reasonably light by not having too many other processes running in the background.
The standard desktop background applet comes with this functionality built in, and creating your own slideshow from scratch is a fun and geeky project.
To do this, you need to create a folder in /usr/share/backgrounds to hold your pictures. I created one called mattpix:
sudo mkdir /usr/share/backgrounds/mattpix
I then copied my pictures in there, and added an xml file called background-1.xml. The settings in the file are fairly self-explanatory, and here’s the format:
<background> <starttime> <year>2010</year> <month>05</month> <day>06</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/mattpix/emirates.jpg</file> </static> <transition> <duration>5.0</duration> <from>/usr/share/backgrounds/mattpix/emirates.jpg</from> <to>/usr/share/backgrounds/mattpix/MistyMorning.jpg</to> </transition> ... </background>
You can pretty much ignore the first few lines under “background”, the interesting bit starts from the <static> tag under the comment.
<duration> is the time in seconds that the picture will stay as the background.
<file> is the path to the background image.
The <transition> section determines how long the cross-fade will last (5 seconds in my case), and what picture we’re transitioning to.
Then there will be another <static> tag for the new image (…/mattpix/MistyMorning.jpg in this case), and another <transition> and so on and so forth. Eventually the whole file is closed with a </background> tag.
When the file is created, I did the following to make the background appear in the Desktop Background applet.
gksudo gedit /usr/share/gnome-background-properties/ubuntu-wallpapers.xml
and added the following section between the tags:
Matt's Pix /usr/share/backgrounds/mattpix/background-1.xml zoom
When you go back to change your screensavers, you’ll notice your new one has appeared. If you’ve left the duration the same, then your background will change every 1795 seconds with a 5 second transition, which is 30 minutes.