XML-Wall

A dynamically changing xml desktop wallpaper generator. Xml-wall is a little script that allows you to easily configure an xml desktop background, without having to go through the pain of actually writing it. While it is not the only application that allows for changing wallpapers, it provides something most others do not: a fade in/out transition in between images.

History

Back in 2007-2008, there were many automatic wallpaper changers, but none that provided a fade in/out transition during changes. Many users (especially Mac users) had requested something similar.

The idea came by in May, as it is evidenced in this ubuntuforums thread:

http://ubuntuforums.org/showthread.php?t=798634

Post # 4 is my answer.

The whole idea of using a xml file as a desktop background is not, and was not, at the moment, new. It had successfully been done in other distributions, like Fedora. It just hadn't been fully exploited.

My idea was later picked up by Hunter Perrin (guywithcable in ubuntuforums), and he wrote a bash script that would take all the image files in one directory and create my xml file using the filenames.

I picked up his script, modified it, expanded it, and created a debian package. The result, is xml-wall.

Credit must be given to Hunter Perrin for carrying on with the project even after I moved to another city and was left with no internet for quite a while. He was the sole maintainer for about a year.

Newer gnome/gtk/nautilus/metacity versions have a built in transition effect, and most modern gnome distros come with a pre loaded xml wallpaper set. Other programs have made it possible to create a dynamically changing wallpaper with transitions.

xml-wall was the first.


Usage:

With xml-wall it is very easy to configure a dynamically changing xml wallpaper, without having to go through the pain of actually writing it.

Usage: The script is designed to use everything it finds within the chosen directory, so it is recommended that you point it to a directory that has only images in it.

It will work only with relatively new versions of GNOME (Ubuntu 7.04, for example, does not allow using xml files as the desktop background).

The resulting xml file is kept in a hidden directory called xml-wall within the user's home folder. And the executable script is kept in /usr/bin/. A brief read should be enough to understand what it does.

Source Code:


#!/bin/bash

# XML Wall
# Wallpaper Transition XML Generator
# Version 1.02
# by Hunter Perrin  and Jon Tohrs 
# Released under the terms of the GNU General Public License, version 2, or any later version published by the Free Software Foundation.
#
# Send us money! -_-

# confirm we want to do this, or cancel

if ! $(zenity --question --no-wrap --window-icon=/usr/share/pixmaps/xml-wall.svg --title "XML Wall" --text "This utility will create a dynamically changing \ndesktop wallpaper set, using images from \na directory of your choice.
\n\nContinue?")
 then
 exit 0
else

# check for working directory, and create it, if necessary

if [ ! -e $HOME/.xml-wall/ ]
 then
 mkdir $HOME/.xml-wall/
fi

# determine the name of the resulting xml file

outfile=$(zenity --window-icon=/usr/share/pixmaps/xml-wall.svg --entry --title="XML Wall" --text="What would you like to call your wallpaper set?")
if $outfile
 then
 exit 0
fi

# check for a file with the same name

if ls -a $HOME/.xml-wall/ | grep $outfile.xml > /dev/null
 then
 if ! $(zenity --question --no-wrap --window-icon=/usr/share/pixmaps/xml-wall.svg --title "XML Wall" --text "A file called $outfile already exists \nWould you like to overwrite it?")
 then
  outfile=$(zenity --entry --title="XML Wall" --text="Please choose a different name.")
  if $outfile
   then
   exit 0
  fi
 else
  rm $HOME/.xml-wall/$outfile.xml
 fi
fi

# determine the length of time each static image should be displayed

wptime=$(zenity --scale --window-icon=/usr/share/pixmaps/xml-wall.svg --title="XML Wall" --text "Choose how long, in seconds, each wallpaper should be displayed." --min-value=10 --max-value=3600 --value=300 --step 10)

if $wptime
 then
 exit 0
fi

# determine the lenght of time for transitions

trantime=$(zenity --scale --window-icon=/usr/share/pixmaps/xml-wall.svg --title="XML Wall" --text "Choose transition delay (seconds)" --min-value=1 --max-value=20 --value=2 --step 2)

if $trantime
 then
 exit 0
fi

# determine where to look for images

cd $HOME

folder=$(zenity --file-selection --directory --title="Choose Image Directory" --window-icon=/usr/share/pixmaps/xml-wall.svg)

if $folder
 then
 exit 0
fi

cd $HOME/.xml-wall/

(
echo 30 ; sleep 1
echo "# Collecting data..." ; sleep 1

# assign the same parameters to all the images (notice how it starts with a transition --otherwise it would not work as expected)

# make sure to initialize the file, so we're not appending to old stuff. Don't forget this means the file now has a blank line.
echo > wallpaper-set.temp

for f in "$folder"/*
do
 echo "  $f" >> wallpaper-set.temp
 echo " " >> wallpaper-set.temp
 echo " " >> wallpaper-set.temp
 echo "  $wptime" >> wallpaper-set.temp
 echo "  $f" >> wallpaper-set.temp
 echo " " >> wallpaper-set.temp
 echo " " >> wallpaper-set.temp
 echo "  $trantime" >> wallpaper-set.temp
 echo "  $f" >> wallpaper-set.temp
done

# define a valid start/end for the xml file.

echo 60 ; sleep 1
echo "# Writing $outfile.xml..." ; sleep 1

tail -n +4 wallpaper-set.temp | tee wallpaper-set.temp
head -n -3 wallpaper-set.temp | tee wallpaper-set.temp

# uncomment this line to cause an error.
#echo > wallpaper-set.temp

# test to make sure there were no errors and we have at least one entry.

if ! cat wallpaper-set.temp | grep static > /dev/null
 then
 zenity --info --window-icon=/usr/share/pixmaps/xml-wall.svg --title="XML Wall" --text="Sorry, an error occured."
 exit 2
fi

# write the file

echo "" > $outfile.xml
cat wallpaper-set.temp >> $outfile.xml
echo "" >> $outfile.xml

# remove temporary file

echo 90 ; sleep 1
echo "# Cleaning up..." ; sleep 1

rm wallpaper-set.temp

# make sure newly created file is readable (just in case ;))

chmod a+r $HOME/.xml-wall/$outfile.xml

echo 100 ; sleep 1

) | zenity --progress --pulsate --auto-close --auto-kill --title="XML Wall" --text="XML set creation in progress..." --window-icon=/usr/share/pixmaps/xml-wall.svg --percentage=0 --width 350 --height 25

# ask whether to apply changes immediately

if ls -a $HOME/.xml-wall/ | grep $outfile.xml > /dev/null
 then
 if ! $(zenity --question --no-wrap --window-icon=/usr/share/pixmaps/xml-wall.svg --title "XML Wall" --text "Your new wallpaper set is located in $HOME/.xml-wall/ \nWould you like to apply your new wallpaper set now?")
  then
  zenity --info --window-icon=/usr/share/pixmaps/xml-wall.svg --title="XML Wall" --text="To apply it later, look for it in $HOME/.xml-wall/"
  exit 0
 else
  # set the newly created file as the desktop background
  gconftool-2 --type=string --set /desktop/gnome/background/picture_filename $HOME/.xml-wall/$outfile.xml 
 fi
else
 zenity --info --window-icon=/usr/share/pixmaps/xml-wall.svg --title="XML Wall" --text="The file was not successfully created."
fi

# get outta there

exit 0

fi