Tuesday, 10 February 2009

XFCE4 Automatic desktop wallpaper changer.

I recently started using XFCE on my Aspire One. I've always liked XFCE and alternated it with Gnome just for variety. Anyway using XFCE full time made me wish for a method to change the wallpaper every X number of minutes so after some hunting and poking this was the solution for automatic wallpaper changing.

First step is to define a list of wallpapers to use in the normal Desktop settings configuration, I'm notgoing to explain in detail how to do it, its fairly straight forward so go explore.

With that configured then XFCE will load a random wallpaper on each login, very nice but not quite what we want is it.

Well it turns out the solution is simply to reload the desktop on a timed interval. Cron takes care of the timed interval part, and the comand to call is:

export DISPLAY=:0; /usr/bin/xfdesktop -reload

You can try it in a terminal before putting it into a cron job. In case you aren[t familiar with cron it is just a case of doing:

crontab -e

If it is the first time you called it then it may ask you what editor to use, just use nano if available as its the easiest to use imho.

Enter this line into the editor:

0,15,30,45 * * * * export DISPLAY=:0; /usr/bin/xfdesktop -reload

Thank you to Ninjanoh who suggested in the comments that this will work in 11.10 by changing -reload into --reload

Ctrl + o to save the file, then Ctrl + x to exit nano.

The wallpaper should now change on the hour and at 15 minutes, 30 minutes and 45 minutes past the hour.


NinjaNoh said...

Thanks for this post!
Side note:
This will work in Ubuntu Studio 11.10 if you change "-reload" to "--reload"

Subbass said...

@Ninjanoh Thank you for the tip, I've added it into the post with credit :)