On Sat, 2004-05-15 at 18:59, Kevin Saenz wrote:
> Can anyone help me out? I am trying to get my background on gnome2.6 
> change randomly after a specified time.

Attached is a little shell script which will cycle the next image from a
list onto Gnome's desktop background.

It's fun to use in from a cron job, or, say, from .bash_profile [if
DISPLAY is set] to change the desktop background every time you pop a
term...

Randomizing a list of images is left as an exercise for the student :) 

[I note that you asked about Gnome 2.6; I'm running 2.4 on this system,
but I imagine it still works the same way]

AfC
Calgary

-- 
Andrew Frederick Cowie
Operational Dynamics Consulting Pty Ltd

Where is he and what time is it there? Use slashtime!
http://www.operationaldynamics.com/time 

#!/bin/sh
# 2003, AfC

# Select the next image from a list and make it the Gnome desktop background
# (or, just specify a filename and it'll use that)
#
# LIST is a file with a list of images, one per line, relative to LIBDIR,
# that you'd like take the next image from. It's not random, rather, it cylces
# through the list one at a time under the assumption that you don't want to
# see a picture you've recently seen again.
#
# The script makes a symlink in LIBDIR called "current.jpg" so you can figure
# out where the background image actually came from if you like it

LIBDIR="/home/andrew/lib/backgrounds"
CURRENT="$LIBDIR/current.jpg"
LIST="$LIBDIR/randomimages.list"

if [ $# -eq 1 ] ; then
	if [ ! -f "$1" ] ; then
		echo "need to specify a file, or, use without args to get a new random image"
		exit 1
	fi
	IMAGE=`pwd`/$1
else

	cat $LIST | perl -e '
		$first = <>;
		while (<>) {
			print "$_";
		}
		print "$first";
	' >$LIST.tmp

	mv $LIST.tmp $LIST

	IMAGE=`head -1 $LIST`

	IMAGE=$LIBDIR/$IMAGE
fi

rm -f $CURRENT
ln -s $IMAGE $CURRENT

gconftool-2 --set "/desktop/gnome/background/picture_filename" \
	--type string $IMAGE
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to