| View previous topic :: View next topic |
| Author |
Message |
Mooff n00b

Joined: 04 Feb 2006 Posts: 7
|
Posted: Sun Mar 05, 2006 4:32 pm Post subject: gnome desktop changer |
|
|
Hi all,
can someone tell me where to find a desktop changer for gnome? (i want a tool which changes the backround every 20min or something by selecting a random wallpaper out of my wallpaper folder)
Search for such a tool and didn't found one.
Hope you can help me
Mooff |
|
| Back to top |
|
 |
Philz n00b


Joined: 31 Oct 2004 Posts: 51 Location: Switzerland
|
|
| Back to top |
|
 |
ZZamboni Tux's lil' helper


Joined: 16 Jan 2004 Posts: 96 Location: Zurich, Switzerland
|
Posted: Mon Mar 06, 2006 7:30 am Post subject: Re: gnome desktop changer |
|
|
| Mooff wrote: | | can someone tell me where to find a desktop changer for gnome? (i want a tool which changes the backround every 20min or something by selecting a random wallpaper out of my wallpaper folder) |
Something like this should work - change IMGDIR as appropriate, write the script to a file, and execute it from cron every once in a while, and it will change the background.
| Code: | #!/bin/bash
IMGDIR=$HOME/lib/images/backgrounds
getrandomimg()
{
ls $IMGDIR | perl -e '@f=<>; print $f[int(rand($#f+1))]'
}
IMG1=`getrandomimg`
gconftool-2 -s /desktop/gnome/background/picture_filename -t string "$IMG1"
|
To execute it from cron say, every 20 minutes, write the file to (for example) $HOME/bin/changebg.sh, and then run "crontab -e" and add a line like this:
| Code: | | */20 * * * * /bin/sh $HOME/bin/changebg.sh |
|
|
| Back to top |
|
 |
PaulBredbury Veteran


Joined: 14 Jul 2005 Posts: 5931
|
Posted: Mon Mar 06, 2006 7:41 am Post subject: |
|
|
Implementation in Python:
| Code: | #!/usr/bin/python
"""
randomwallpaper - finds a random picture and sets it as wallpaper.
"""
import os
from random import choice
# List of all the folders you want to scan
folders = ['/home/whoever/Wallpaper', '/home/whoever/Another wallpaper directory']
def doubleUpSingleQuotes(strSQL):
return strSQL.replace("'", "''")
os.nice(20)
imgs = []
for d in folders:
if os.path.exists(d) and os.path.isdir(d): # Is it a valid folder?
for f in os.listdir(d): # Get all files in that folder
imgs.append(d + os.sep + f) # Add it to our list
wallpaper = doubleUpSingleQuotes(choice(imgs)) # Get a random entry from our list
cmd = "gconftool-2 --type=string --set /desktop/gnome/background/picture_filename '" \
+ doubleUpSingleQuotes(wallpaper) + "'"
os.system(cmd) # Set wallpaper |
|
|
| Back to top |
|
 |
duckz Apprentice

Joined: 26 Jun 2007 Posts: 157
|
Posted: Thu Apr 17, 2008 9:45 am Post subject: |
|
|
| Code: |
#!/bin/bash
IMGDIR=/home/duckz/Images
SLEEPTIME=60 # in seconds
while [ 1=1 ] ;
do
getrandomimg()
{
ls $IMGDIR | perl -e '@f=<>; print $f[int(rand($#f+1))]'
}
IMG1=`getrandomimg`
e17setroot -s $IMGDIR/$IMG1
Esetroot -s $IMGDIR/$IMG1
sleep $SLEEPTIME
done
|
slightly modified for enlightenment background change and added time control to change the background every xxx seconds. _________________ So you want to be a GENTOO?
emerge -va http://duckzland.ismywebsite.com <- install my blog in gentoo
./configure http://papero.0fees.net <- configure your wallpaper |
|
| Back to top |
|
 |
|