Friday, January 01, 2010

Create wallpaper slideshow in Ubuntu 9.10

First of all, happy new year! Nothing like the morning of a new year to be messing around with Linux and Python!

One of the new things in Ubuntu 9.10 is that you can now use a wallpaper slideshow for your desktop, which will cycle your desktop wallpaper at regular intervals from a selected pool of wallpapers. The default Ubuntu 9.10 comes with a space-themed wallpaper slideshow, but there is apparently no option to create your own ones. However, the configuration is stored in plaintext XML files, one in /usr/share/gnome-background-properties and the other in the corresponding directory where the images are stored, in /usr/share/backgrounds.

The following Python script will automatically create these two XML files so that you can set a wallpaper slideshow with the images of your preferences.

Slideshow Builder script
(Right-click and select "Save Link As..", or the equivalent in your browser).

Here's the instructions. You will need root access since the directory where you're doing the operations, /usr/share/, is owned by root. Simply use sudo (or sudo -i if you're lazy).

1) Create a directory in /usr/share/backgrounds with the name of your slideshow. For instance, if the desired name is 'space', the dir should be called '/usr/share/backgrounds/space/'.

2) Copy all the wallpaper images to that folder. The supported formats are jpg, png, gif and bmp.

3) Run the Python script in the images directory. This will automatically create two xml files: one in the (current) images directory, and another one in /usr/share/gnome-background-properties.

4) That's all! You can now select the slideshow in the Gnome wallpaper selection interface.

A sample usage of the script is shown in the following image:


And the slideshow now appears in the desktop Background selection screen:


Update: I've fixed the dead link to the script.

17 comments:

Luis Sanchez said...

Very nice, as a matter of fact I am just playing with my new wallpaper slideshow ;)

SäNtä said...

Great Script!!!!

Thank you very much...

If you let me, I can translate the post into Catalan and post it in my blog so my friends and Catalan community have access to it...

Of course I'd say it not mine the script and I'll post your blog as the original post...

Do you let me?

Thank you very much!

Luis Sanchez said...

As far as I concern, go ahead and translate it. I dont think Claudio will have any objection with it :)

Laura said...

Wonderful, thank you for sharing your efforts!

Matt :o) said...

Great work on the script! Yours is definitely the cleanest and most straight forward approach to creating wallpaper slidshows that I have found. Thanks!

Ghost|BTFH said...

Just an FYI: All that work is not necessary. You can create an xml file and keep it in a local directory (only 1 xml file is necessary) and you can have rotating wallpaper from it.

The format is the same as the cosmos.xml



2010
01
01
00
00
00



300.0
/home/yourlogin/location_of_image/image.png


5.0
/home/yourlogin/location_of_image/image.png
/home/yourlogin/location_of_image/image.png


300.0
/home/yourlogin/location_of_image/image.png


5.0
/home/yourlogin/location_of_image/image.png
/home/yourlogin/location_of_image/image.png



is how long to display the image (in seconds)


is how long it takes for one image to replace another.

Just remember to set a transition back to the first file so it'll keep rotating forever.

Cheers,
Ghost|BTFH

Ghost|BTFH said...

Sorry, this stupid thing wants to believe everyone naturally types in < > brackets for the sake of html.

That should show:

(background)
(starttime)
(year)2010(/year)
(month)01(/month)
(day)01(/day)
(hour)00(/hour)
(minute)00(/minute)
(second)00(/second)
(/starttime)

(static)
(duration)300.0(/duration)
(file)/home/yourlogin/location_of_image/image.png(/file)
(/static)
(transition)
(duration)5.0(/duration)
(from)/home/yourlogin/location_of_image/image.png(/from)
(to)/home/yourlogin/location_of_image/image.png(/to)
(/transition)
(/background)

(duration)300.0(/duration) is the time to display in seconds.

(transition)
(duration)5.0(/duration) shows the transition time in seconds.

Just remember to set a transition back to the first file so it'll keep rotating forever.

Just remember to replace ( ) with < >

Cheers,
Ghost|BTFH

rabiabidabi said...

Hi and thannks. This is an easy to follow set of instructions. Works great.

I have no programming background, so please forgive me for these questions.

1) Can I delete the .py script from my desktop after I run it?

2) How do I add more pics to the new folder?

thanks

Anonymous said...

yes

abdominoplasty surgery said...

The default Ubuntu 9.10 comes with a space-themed wallpaper slideshow, but there is apparently no option to create your own ones.

tipsotto said...

Hi, Thanks for the great post. But SlideshowBuilder.py is not there anymore. I would love to use it. Could you please repost the script or reupload it. Thank you in advance.

Rohan Jain said...

I am unable to download SlideshowBuilder.py from the link you posted

Meithan West said...

Thanks for your feedback everybody!

I've fixed the dead link. It should work now.

I'll look into what Ghost|BTFH said. I could also improve the script to be more interactive and easy to use.

Also, I should've included a license disclaimer in the script (GPLv3 is a good choice); I'll do it on the next update. This is Free Software. Feel free to use, redistribute and modify (which includes translating) the script to your heart's extent :).

Anonymous said...

Here's a BASH script that does the same from and can be ran with any picture folders.

#!/bin/bash

if [ $# -ne 1 ]; then
echo "Usage: $0 "
exit 1
fi

if [ "`id -u`" != "0" ]; then
echo "You must have root privileges to execute this script!"
exit 1
fi

if [ ! -d "$1" ]; then
echo "The argument should be a folder!"
exit 1
fi

DIR_NAME="`basename $1`"
BACKGROUNDS="/usr/share/backgrounds/"
DIR="$BACKGROUNDS$DIR_NAME"

if [ -d "$DIR" ]; then
echo "The folder \"$DIR\" already exists, do you want to continue overwriting it? [Y/N]"
read cont
if [ -n "$cont" -a "$cont" != "Y" -a "$cont" != "y" ]; then
exit 0
fi
fi
echo "Copying \"$1\" to \"$BACKGROUNDS\"..."
cp -rf "$1" "$BACKGROUNDS"

PROP_DIR="/usr/share/gnome-background-properties"
PROP="$PROP_DIR/$DIR_NAME.xml"
SLIDES="/usr/share/backgrounds/$DIR_NAME/background-1.xml"

echo "Writting \"$PROP\"..."
echo -e "\n\n\
\t\n\t\t$DIR_NAME\n\t\t$SLIDES\n\t\n" > "$PROP"

echo "Writting \"$SLIDES\"..."
echo -e "\n\t\n\t\t2010\n\t\t11\n\t\t18\n\t\t00\n\
\t\t00\n\t\t00\n\t" > "$SLIDES"

find $DIR -maxdepth 1 -type f -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" | while read IMG; do basename $IMG; done | \
while read NEXT; do if [ -n "$PREV" ]; then echo -e "\t\n\t\t5.0\n\t\t$DIR/$PREV\n\t\t$DIR/$NEXT\n\t"; fi;\
echo -e "\t\n\t\t1795.0\n\t\t$DIR/$NEXT\n\t"; PREV=$NEXT; done >> "$SLIDES"

echo "" >> "$SLIDES"

echo "Done."

WS said...

Cortina does this and has a FS watcher, so it automatically updates when you add images. https://help.ubuntu.com/community/Cortina

Enio Marconcini said...

great script, works fine! but pay attention: I had trouble to run with image filename that had space, ro I had to use pyrenamer to change spaces to _

Anonymous said...

Is this any reason why this would create the xml file(s) but without the image files within the script? The xml created for me was simply a generic script with the introductory information, start time etc, in.

Any help much appreciated.

Thanks