Tuesday, November 24, 2009

Create Your Own GNOME Background Slideshow

One of the cool new features in the fresh GNOME 2.28 desktop environment is the ability to use a set of multiple images as your background, images that will transition between eachother at set timeframes. Unfortunately, as far as I know, there's not an easy, in plain view, way of creating your own sets, with your own pictures.



So, I tried to find out how they were created by going to their source directory, which is /usr/share/backgrounds. All the wallpapers were there, but the Cosmos set had a separate directory, as I was expecting. Inside are, obviously, all the pictures that will loop on your desktop once you activate the set, but the key piece of our little puzzle has to be the background-1.xml file. Before we begin editing it we need to operate as root within the folder. To do that, simply open a Terminal, type sudo nautilus, enter your password and a new folder window called root will pop up in a few moments.

Now click on "File System" on the left, navigate to the /usr/share/backgrounds directory and create a new folder. Don't forget to name it according to whatever theme your pictures might have, in my case, "jewel". Proceed inside the folder (sounds fancy, right? :D ) and leave the window open as it is.

The next step is to select the pictures that you want included in the set and copy them. You don't need to open another root nautilus, simply navigate to your pictures directory as you normally do, select the files and copy them. Go back to the administrator-ran "jewel" directory and paste those babies in there.

What's missing now is the xml file to tell GNOME how to handle the images. A bit of a disclaimer first: I know NOTHING about programming, advanced web design or any other thing that has to do with coding. With that out of the way, it's obvious that I stole the background-1.xml file from the "cosmos" folder that was already in there. Go up a level, copy it, go back to your folder, paste it, and rename it to, say... background-2! Thumbs up! :D

What you need to do next is open the file in your favorite text editor. I use gedit, so right click on the file, select "open with" and gedit. I didn't want to mess with the transition speed settings, so it's best to leave them untouched. What we need to change are only the paths to the images. There are two sections for each image: static and transition. In the first static section, replace the path right next to with the path to your first image. To easily copy a path, right click on an image, go to Properties and there it is, in the Location field. You will only need to replace the filename manually. In my case, I replaced this line: /usr/share/backgrounds/cosmos/cloud.jpg with this line: /usr/share/backgrounds/jewel/jewel-01.JPG. In the transition section, you can see that there are two paths, one that leads to the first image and the other that leads to the next image in the set. This part instructs GNOME to transition between the first and the second image in your set. The next section is again, a static one, in which you need to type the path to the second image. The following, "transition" section needs the paths to the second and third image. Hope you're still with me here! :) Now go on replacing the paths until you run out of images. Be careful though, the last section, before the line, has to be a transition between the last image in your set and the FIRST one, so it can loop. You can then remove the extra sections. Sections begin with either or and end with or .

Very important! Be very careful with lower, upper-case characters. Be sure to write the filenames exactly as they are in your folder. I was quite dazzled on why my xml won't work until I realized my images had a .JPG extenstion instead of .jpg. :)

Now save the XML file, right click on your desktop, go to "Change desktop background" and simply drag the XML file inside the Background window. You can also click the "Add" button, select "All files" right above the "Open" button and navigate to the XML file and open it.

A picture is worth 1000 words, right? Well, in this case, the following 15 FPS video is worth 3975000 words! So, instead of having a picture for every step described above, here's a video! I don't even know why I bothered to write the whole thing. Oh well... :) Enjoy!


So... that's pretty much it, folks! Have a great day and come back! I will try to post more than one article/light year from now on. :)

UPDATE 08.12.2009

Ah... the beauty of Linux... I was almost certain that there would be an easier way to flip through a bunch of wallpapers in GNOME. How right I was. The awesome Linux Journal's Shawn Powers posted a "Tech Tip of the Day" showing off a program called Drapes that does just that. So, without further ado, here's the video:








UPDATE 02.07.2010

Ah... the beauty of Linux... I really have to express that feeling of admiration yet again, as one of my readers have created THIS awesome piece of automaton. You just input the path to your pictures, a delay time and the script does its magic, creating a fully functional XML file which works just like the one you would modify by following my tutorial. Thank you very much, Mr. Mike. The Force of Open Source is definitely strong in you. :D


23 comments:

  1. Can't you symlink to the image files instead of copying them?

    ReplyDelete
  2. Yes, you can. Thanks for pointing that out!

    You can put any location instead of the regular /usr/share/backgrounds path.

    But it's cleaner and easier to transfer the whole slideshow pack to another computer if the pictures are in the dedicated directory.

    ReplyDelete
  3. Dude! Excellent one, I will be passing this on!

    ReplyDelete
  4. May i ask how do you copy the items then post them to yuor slideshow? And this is very stupid why are there only three comments and why the heck does it take so long for an answer. do yo guys even know that your site is posted and lame. When are you pepole going to contact me back

    ReplyDelete
  5. I explained the copying/pasting process in the article.

    And this is very stupid because there are only three comments? WHAT? :)

    And our site is "posted"? What does that even mean?

    ReplyDelete
  6. hey! what's the title of the song from the 1st video? :)
    thx

    ReplyDelete
  7. It's Come Here to Me (The Ice Cream Man Song) performed by Emma Wallace. :)

    ReplyDelete
  8. wow, that was fast :)!
    thx for the info and your tutorial!

    ReplyDelete
  9. And thank you for passing by. :) Enjoy the song!

    ReplyDelete
  10. Would it be possible to set individual attributes for each image? As in this one is "zoomed", this one is "tiled" separately?

    ReplyDelete
  11. I hate to admit it, but I have absolutely no idea. :))

    ReplyDelete
  12. hey danny even i did, later i got ur article, but great work buddy.

    ReplyDelete
  13. http://tinyurl.com/xmlmaker

    i wrote this script to make the XML's, it's easy to use

    ReplyDelete
  14. Oh wow, nice one, Mike! Thanks a lot. :)

    ReplyDelete
  15. And thank you, Danny -- it was reading your tutorial that prompted me to take the time and contribute.

    an xml it wrote is running for me right now. :)

    ReplyDelete
  16. There is a python script for creating the slideshow automatically, check it

    http://gnome-look.org/content/show.php/Wallpaper+Slideshow?content=125178

    ReplyDelete
  17. here is a bash script for creating slideshow automatically ;) http://code.google.com/p/mkbackground/downloads/list

    ReplyDelete
  18. Totally awesome, thanks for the explanation! I knew there was an easy way.

    ReplyDelete
  19. #!/bin/bash
    # make-xml.sh - create desktop background control file
    # from list of images in current dir

    tmpfile=background-tmp.xml
    finalfile=background-2.xml
    bakfile=background-2.xml.prev

    # invarient header
    echo "


    2009
    08
    04
    00
    00
    00
    " > $tmpfile

    # set up bash array of image names - add valid image name extensions as desired
    declare -a imgs
    imgs=(`ls *.jpg *.JPG *.png *.PNG 2>/dev/null`)
    num_imgs=${#imgs[*]}

    # create the xml using image names
    for ((i=0;i<$num_imgs;i++)); do
    (( j = $i + 1 ))
    echo "

    1795.0
    /usr/share/backgrounds/all/${imgs[$i]}


    5.0
    /usr/share/backgrounds/all/${imgs[$i]}
    /usr/share/backgrounds/all/${imgs[$j]}
    " >> $tmpfile
    done

    echo "" >> $tmpfile

    cp $finalfile $bakfile
    mv $tmpfile $finalfile
    #now just load $finalfile as your background

    ReplyDelete
  20. how to set background options like zoom, tile, scale, fill, etc...
    ??????

    ReplyDelete