So I have been playing around with Ubuntu's changing backgrounds and thought someone here
might appreciate the fruits of this labour
So if you copy the 2 pieces of code below into your Pictures directory, you can make as many
of these types of backgrounds as you like
Template: This is the standard template used to create the background transitions:
Code:
<background>
<static>
<duration>600.0</duration>
<file></file>
</static>
<transition>
<duration>5.0</duration>
<from></from>
<to></to>
</transition>
</background>
Please this in a file in your Pictures directory and call it: background_template.xml
Code: This is the code to create each individual transition file:
Code:
#!/bin/bash
(( $# != 2 )) && { echo "Usage: $0 DIRECTORY FILENAME [EXTENSIONS]"; exit 1; }
DIRECTORY=~/Pictures/$1
FILENAME=$DIRECTORY/${2}.xml
TEMPLATE=~/Pictures/background_template.xml
[[ -d $DIRECTORY ]] || { echo "No such directory $DIRECTORY"; exit 1; }
exec >$FILENAME
START="<background>"
STATIC=$(awk '/stat/,/from/' $TEMPLATE)
TRANSITION=$(awk '/to/,/trans/' $TEMPLATE)
END=$(awk 'END{print}' $TEMPLATE)
echo $START
for PIC in $DIRECTORY/*.jpg # If you want more extensions in here replace jpg with {ext1,ext2,...}
do
(( x++ )) && echo "$TRANSITION" | sed "/to/s@><@>$PIC<@"
echo "$STATIC" | sed -r "/file|from/s@><@>$PIC<@"
done
echo -e "$TRANSITION\n$END"
if grep -q '*.' $FILENAME
then
echo -e "No files with appropriate extension(s) were found in:\n\n$DIRECTORY\n" >&2
rm $FILENAME
fi
exit 0
This code will place the file, with name of your choosing, into the directory where the
pictures are that you wish to transition over.
To run code simply issue:
Code:
./name_of_script <folder_to_look_in> <file_name>
Enjoy
If any issues please let me know