Random Wallpaper in Gnome December 1, 2005
Posted by Carthik in guides, ubuntu.trackback
I am a wallpaper/background packrat with over a Gigabyte of wallpapers. Now the problem was that there is no in-built mode in Gnome to use a random wallpaper from among the wallpapers in a directory. In looking around, though, I found a few scripts and tools that make this very easy. These tools help you to “rotate” a set of backgrounds, displaying one of many wallpapers at random on your desktop. You can set these to change the wallpaper at various times, or at log-on time.
Here is a summary of the tools and scripts for other folks looking for a random gnome background changer:
Change Wallpaper from Gnome Hacks : This one can use a random image from a folder you specify or download random wallpapers on the fly from the art.gnome.org website and use that, or specify a folder full of images. You can add the script to be run at session startup.
Davyd’s Python Script : Short and sweet python script – picks images from a folder/directory. Needs cronjob.
Richi’s adaptation that uses the .gnome2/backgrounds.xml file: An adaptation of Davyd’s script that changes the wallpaper by editing the .gnome2/backgrounds.xml file. Different strokes for different folks!
Tomasz’ Random Wallpaper Changer: Choice is great! One more variation on the theme.
Gnome Background Changer: It uses the picture list defined in “Change Desktop Background / Desktop Background Preferences” dialog (in ~/.gnome2/backgrounds.xml) or you can specify a directory with pictures in it. You can define how long a picture will be shown before the background is changed. This script is made to run in the background indefinitely (until you log out), so it should be put into the background when started from the shell (gbchange &) or better be started from GNOME’s session management.
You can also use $sudo apt-get install wallpaper-tray to install a wallpaper changer from the command line. This will install wallpaper tray, but be warned it does not work too well with Edgy.
If you need the background changed each time you start a new session (that is, log on, for us non-geek folks), then use a script from above, and add it, after you have edited it to add the right directory etc, and ensuring it works to “System->Preferences->Sessions->Startup Programs”, and you’re all set.
I should think the gnome folks should include a tool to use a random background by default. Maybe it is just that none of the gnome desktop maintainers have are addicted to colorful backgrounds yet
Digg This!






I seem to remember another- it puts a thumbnail of a wallpaper in your panel, and changes the background at some interval – it was called gdswitcher… something like that. Ring any bells?
nevermind, I found it:
http://planetearthworm.com/projects/wp_tray/
Chris, that sounds like a wonderful idea, and very useful tool, but it does not work on Ubuntu. I tried installing from source, and using alien to convert the rpm. Looks like some libboost_filesystem.so file cannot be find, which is causing all the problems.
It would be great if there was a ubuntu .deb for that tool.
How odd, I could swear that’s the one I installed on Mom’s computer. I’ll look again and get back to you.
I does work in Ubuntu, but you need an older version. I think I found a .deb for it somewhere, probably from Debian, or installed the Debian package from the page, or something like that.
However, now I’m trying to compile it on Fedora 4, with no success. Might just have to go for a script instead.
[...] ?о однажды на изве?тном блоге ubuntu.wordpress.com наткнул?? на по?т про ?мену обоев, и решил таки ут?нуть ?ебе один понравивший?? ?криптик. Тот, который оперирует только над обо?ми, выбранными в gnome’ов?кой обойной панельке. [...]
Here is another version… I don’t have all my pics in a single dir… so this takes the tree of files and pick a random one for the wall paper…
I put this in a file which is executed by .bash_profile so eveytime I open a new shell I get a new background…
Peter
#
# Created by Peter A. Murray
# pick a random jpg for the desktop background.
#
# choose input tree
#
export BACKGROUND_DIR=~/Desktop/bild/2005
#export BACKGROUND_DIR=~/Desktop/bild/2006/Winter-Jan
# build up the array
array1=( `find “$BACKGROUND_DIR” -name \*.jpg | tr ‘\n’ ‘ ‘`)
element_count=${#array1[*]}
arrayPos=$RANDOM
# get a random number less than length of array
let “arrayPos %= $element_count”
picToUse=${array1[$arrayPos]}
# set the background image
/opt/gnome/bin/gconftool-2 -t str -s /desktop/gnome/background/picture_filename “$picToUse”
My prefered and shortest option is:
1) install randomize-lines
2) add the two line in a script
gconftool-2 -t str –set /desktop/gnome/background/picture_filename “`find /home/thierry/MesDocuments/Mes\ images/Photos -name \*.jpg | rl -c 1`”
gconftool-2 -t str –set /desktop/gnome/background/picture_options “scaled”
3) launch the script via Gnome Session properties (once at each boot), or launch the script via crontab.
You can use apt-get to install wallpaper-tray
Personally I could use pointers on how to install / cron
Otherwinse, excellent
wallpaper-tray in ubuntu is glade-broked, at the moment. use gconf-editor to update the xml file and you’re golden.
this is a great tutorial/script for changing wallpapers:
http://ubuntuguide.org/wiki/Ubuntu:Edgy/TipsAndTricks#How_to_set_up_.28automatic.29_background.2Fwallpaper-changer_application_for_GNOME
recursive folders, options for zooming/filling/tiling/exclusion. good stuff
“Change Wallpaper from Gnome Hacks” is the same link as “Linux Desktop Hacks changer”!!
Peter, thanks for catching that – I fixed it – I suspect it was two different things, but I messed up copying the URL – in any case, there is only one now.
Is there a shell script that would display random desktop backgrounds with a “fade” transition between them, similar to the one that comes with OS X?
Thanks!
Hey thanks!
Out of the ones you listed, I found Richi’s script to be the best for me.
http://richip.dhs.org/change-background.py
I downloaded a Python script long time ago and modified it to make it a bit cleaner and more useful (sorry, original copyright text lost). It can now also show digital camera raw files by creating a ppm on the fly using dcraw in /tmp. NEF’s only for now, but should be really easy to change …
Don’t know anything about Python, so might not be really optimized
#!/usr/bin/python
#
# wallpaper.py
#
# A script to change your gnome wallpaper to a random background image
#
import gconf
import os
import sys
import random
import mimetypes
import time
sys.path.append(os.environ["HOME"])
sys.path.append(os.path.join(os.environ["HOME"],’.wallpaperchanger’))
configdir=os.path.join(os.environ["HOME"],’.wallpaperchanger’)
# Build a list of all picture files
imageitems=[]
for rootdir,dirlist,filelist in os.walk(sys.argv[1]): # recursive scan for filenames
for file in filelist:
# Check for NEF first
if (file.endswith(’.nef’) or file.endswith(’.NEF’)):
imageitems.append(os.path.join(rootdir,file))
else:
mimetype=mimetypes.guess_type(file)[0]
if mimetype and mimetype.split(’/')[0]==”image”:
imageitems.append(os.path.join(rootdir,file))
if len(imageitems)”+tempfile)
client.set_background(tempfile)
else:
client.set_background(file)
gconftool-2 -t string -s /desktop/gnome/background/picture_filename $(find /home/knarf/wp -iregex ‘.+\.\(jpe?g\|bmp\|png\|gif\)’ | perl -e ‘@a=;print $a[rand @a];’)
Just replace “/home/knarf/wp” with your wallpaper folder.
After trying all of these approaches, I found “Desktop Drapes” which is installable via apt-get (or the Ubuntu Applications -> Add/Remove menu); it is simple and clean, and rotates my wallpapers. Make sure to select “All available applications” in the Add/Remove dialog, and then search for “drapes” to find it.
Heres another one I just made:
http://www.abcpchelp.com/random_bg/random-background-rotation-php-script.php
stand allow script
I’m with fb webilder is a very good way to get a Webshots type background in Linux.
[...] o WT, odradzał tę aplikację, dla mnie jednak okazała się idealna. Odsyłam zresztą do tej notki – jest napisana zrozumiale i zawiera przydatne wskazówki dla tapetomaniaków. Tutaj jeszcze o [...]
There is a program called drapes that will rotate the background for you. You can set the interval and the directory.
Jessi’s suggestion (drapes) was the best solution in my case, as I wanted to use the wallpapers set in the Gnome config panel… Thanks!
[...] webilder wallpaper-tray (package manger වෙතින් ලබා ගන්න) (Gnome Wallpaper මාරු කිරීමට වෙනත් විධි ) [...]
Jessi you are the best! Drapes works perfectly in my case! Thank you
[...] most attuned to exactly what I wanted from a wallpaper switching program was the one called “wallpaper-tray” on Ubuntu. Other than that, it’s been a myriad of lame ducks…most programs try [...]