Bash script to generate gnome wallpaper stack xml
This quick script that generates an xml which can be consumed by the backgrounds config. This script was created by ozhoo in ubuntuforums http://ubuntuforums.org/showthread.php?t=1344787.
First you need to open wallpaper.sh file
gksudo gedit /usr/bin/wallpaper.sh
Copy and paste the following script
#!/bin/bash
#
# usage:./wallpaper.sh background_dir_1 background_dir_2 background_dir_3
#
# description: simply generate a backgrounds xml that can be consumed by gnome's background configuration
#
# author: ubuntuforums.org username 'ozhoo'
#
# note: only looks for .JPG and .jpg files
# output file
FILENAME=backgrounds.xml
# start time
YEAR=2009
MONTH=08
DAY=01
HOUR=00
MINUTE=00
SECOND=00
# time to show background (seconds)
WALLDURATION=900.0
# transition time (seconds)
TRANSDURATION=5.0
# script specifics
DIRS=$*
T1="echo -e \t"
T2="echo -e \t\t"
echo "" > "$FILENAME"
${T1}"" >> "$FILENAME"
${T2}"${YEAR} " >> "$FILENAME"
${T2}"${MONTH} " >> "$FILENAME"
${T2}"${DAY} " >> "$FILENAME"
${T2}"${HOUR} " >> "$FILENAME"
${T2}"${MINUTE} " >> "$FILENAME"
${T2}"${SECOND} " >> "$FILENAME"
${T1}" " >> "$FILENAME"
get_first()
{
for d in $DIRS; do
find "$d"|grep -i .jpg|while read j; do
echo "$j"
break
done
break
done
}
FIRST="$(get_first)"
${T1}"" >> "$FILENAME"
${T2}"${WALLDURATION} " >> "$FILENAME"
${T2}"${FIRST} " >> "$FILENAME"
${T1}" " >> "$FILENAME"
${T1}"" >> "$FILENAME"
${T2}"${TRANSDURATION} " >> "$FILENAME"
${T2}"${FIRST} " >> "$FILENAME"
for d in $DIRS; do
find "$d"|grep -i .jpg|while read j; do
if [ "$j" == "$FIRST" ]; then
continue
else
${T2}"${j} " >> "$FILENAME"
${T1}" " >> "$FILENAME"
${T1}"" >> "$FILENAME"
${T2}"${WALLDURATION} " >> "$FILENAME"
${T2}"${j} " >> "$FILENAME"
${T1}" " >> "$FILENAME"
${T1}"" >> "$FILENAME"
${T2}"${TRANSDURATION} " >> "$FILENAME"
${T2}"${j} " >> "$FILENAME"
fi
done
done
${T2}"${FIRST} " >> "$FILENAME"
${T1}" " >> "$FILENAME"
echo " " >> "$FILENAME"
Save and exit the file.
Now you need to give excute permissions for your script
chmod +x wallpaper.sh
Using this script
/usr/bin/wallpaper.sh background_dir_1 background_dir_2 background_dir_3
Note:- This script only looks for .JPG and .jpg files
First you need to open wallpaper.sh file
gksudo gedit /usr/bin/wallpaper.sh
Copy and paste the following script
#!/bin/bash
#
# usage:./wallpaper.sh background_dir_1 background_dir_2 background_dir_3
#
# description: simply generate a backgrounds xml that can be consumed by gnome's background configuration
#
# author: ubuntuforums.org username 'ozhoo'
#
# note: only looks for .JPG and .jpg files
# output file
FILENAME=backgrounds.xml
# start time
YEAR=2009
MONTH=08
DAY=01
HOUR=00
MINUTE=00
SECOND=00
# time to show background (seconds)
WALLDURATION=900.0
# transition time (seconds)
TRANSDURATION=5.0
# script specifics
DIRS=$*
T1="echo -e \t"
T2="echo -e \t\t"
echo "
${T1}"
${T2}"
${T2}"
${T2}"
${T2}"
${T2}"
${T2}"
${T1}"
get_first()
{
for d in $DIRS; do
find "$d"|grep -i .jpg|while read j; do
echo "$j"
break
done
break
done
}
FIRST="$(get_first)"
${T1}"
${T2}"
${T2}"
${T1}"
${T1}"
${T2}"
${T2}"
for d in $DIRS; do
find "$d"|grep -i .jpg|while read j; do
if [ "$j" == "$FIRST" ]; then
continue
else
${T2}"
${T1}"
${T1}"
${T2}"
${T2}"
${T1}"
${T1}"
${T2}"
${T2}"
fi
done
done
${T2}"
${T1}"
echo "
Save and exit the file.
Now you need to give excute permissions for your script
chmod +x wallpaper.sh
Using this script
/usr/bin/wallpaper.sh background_dir_1 background_dir_2 background_dir_3
Note:- This script only looks for .JPG and .jpg files













