Xfce: rotating backdrops · Nov 9, 06:24 PM by Dylan Doxey
Ever wanted your Xfce backdrop to automatically change, and fade to another?
Well,xfdesktop doesn't support faded transitions. But it does support being reloaded after the configured image has been changed. So, one could configure a set of images which morph from one to the next, and then reload the series in succession.
Thanks to Travis Beckham's work on Squidfingers.com we have the perfect set of images to start with. Here's a couple of samples:
![]() | ![]() |
Travis gives us permission to use his images, so long as we give him credit. I wrote this script to conveniently harvest them from his website:
#!/bin/bash
# get_patterns
a=0
while [ $a -le "2" ]
do
a=$(($a+1))
printf -v number "%03d" $a
wget http://www.squidfingers.com/assets/patterns/pattern_$number.gif
done
Then I wrote a script to use ImageMagick convert to create the transition images between.
#!/bin/bash
# interpolate_transitions
i=0
while [ $i -le "157" ]
do
j=$(($i+2))
i=$(($i+1))
echo $i $j
printf -v inumber "%03d" $i
printf -v jnumber "%03d" $j
if [ ! -f pattern_$jnumber.gif ]
then
jnumber=001
fi
k=8
echo convert -morph $k pattern_$inumber.gif pattern_$jnumber.gif result.gif
convert -morph $k pattern_$inumber.gif pattern_$jnumber.gif result.gif
while [ $k -ge "1" ]
do
k=$(($k-1))
convert "result.gif[$k]" pattern_$inumber.$k.gif
done
rm result.gif
done
The result is like:
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
Now I need something which swaps out the transition images and calls xfdesktop -refresh. Awesome, that sounds like another script writing opportunity.
#!/bin/bash
# fade_backdrop
update_backdrop () {
dir=$1
number=$2
if [ ! -z "$3" ]
then
transition_number=.$3
else
transition_number=$3
fi
echo "# xfce backdrop list" > $dir/backdrops.list
echo $dir/pattern_$number$transition_number.gif >> $dir/backdrops.list
/usr/bin/xfdesktop -reload
}
export DISPLAY=:0
dir=/usr/share/squidbackdropper
number=`/usr/bin/tail -1 $dir/backdrops.list | awk -F_ '{print $2}' | awk -F. '{print $1}'`
if [[ $number == "" ]]
then
number=001
fi
backdrop_index=`echo $number | sed -r 's/^[0]+//g'`
# do the transition backdrops
transition_index=-1
while [ $transition_index -lt "7" ]
do
transition_index=$(($transition_index+1))
update_backdrop $dir $number $transition_index
sleep 1
done
# advance to the next backdrop
backdrop_index=$(($backdrop_index+1))
printf -v number "%03d" $backdrop_index
if [ ! -r $dir/pattern_$number.gif ]
then
# loop around to the first if out of images
backdrop_index=1
number=001
fi
update_backdrop $dir $number
You may have noticed that the script above is writing the image file names to the file /usr/share/squidbackdropper/backdrops.list. For this to work you must configure your desktop to use that file as the backdrop image list file.
Basically this just means that you're using a list of one image, which will change periodically based on the function of the fade_backdrop script.
To wrap it up, you'll need a cron job which periodically calls the fade_backdrop script.
crontab -e
# m h dom mon dow command */1 * * * * /usr/share/squidbackdropper/fade_backdrop
Where I put */1, you'll want to put the number of minutes between transition events. Perhaps */10 or */30 if every minute is a little too often for you.
If you're not in the mood for recreating all this work, then you can just download the whole package here: squidbackdropper.zip
And for the finishing touch, here's the demo video:
Well, most of the work was already done by the time I was able to clearly observe the desktop flicker associated with the reload operation. I think the authors of the xfdesktop program did not intend for routine reloads to be called this way. But, what the heck. Why spoil the fun with perfectionism?
Happy computing!

Commenting is closed for this article.
Using ndsiwrapper on Vine Linux Fixed Resolution: Acer TravelMate 4200










