Jump to content

Nautilus & GNOME 2.0: How to change wallpaper on the fly


Guest lcj
 Share

Recommended Posts

Hi!

 

I've been working with GNOME 1.4 now it's time for 2.0. I noticed that if you set nautilus to draw your background I cannot change my wallpaper any more.

So after asking about gnomeconf-2 at #gnome-art (irc.gnome.org) I've written very simple script.

 

HOW TO USE IT:

 

1. Put all your favourite wallpapers into one directory

2. Set this directory inside script.e/

3. Run it :)

 

I've done this via cron job:

 

$crontab -e

and put:

0-59/5 * * * * /home/user/bin/wallpaper_changer_script

 

TO DO:

Random value shoud me calculated in different way... Any ideas ?

 

The script:

 

---cut here---

#!/bin/bash

# by lcj@klonex.com.pl © 2002.10.22

# thanks goes to: Cegla@klonex.com.pl, star @ #gnome-art

# Purpose: Change randomly wallpaper in Gnome, if nautilus is set to draw desktop

# Usage: change the value: WALLPAPERS_LOCATION to directory with wallpapers,

# remember the / at the end. There should be no other files than the

# pictures interned for wallpaper in that directory

# version: 0.2

# history:

# 22-Oct-2002, version 0.2 Initial release

# 22-Oct-2002, changed to work with pictures from given directory

 

# CHANGE THE DIR BELOW TO YOUR WALLPAPER DIRECTORY:

####################################################

WALLPAPERS_LOCATION="/home/lcj/Graphics/wallpapers/"

####################################################

# main code, lets enter the directory

cd $WALLPAPERS_LOCATION

# counting number of files

ile=`ls | wc -l | tr -d "[ ]"`

#reset counter to 1

counter=1

# now get every file name and put it ino pic[licznik] table

for i in `ls`

do

pic[counter]=${WALLPAPERS_LOCATION}$i

((counter=counter+1))

done

# now lets get the RANDOM number

which_pic=$RANDOM

# we have to decrease it a bit. It won't be that random now :)

while [ $which_pic -gt $ile ]

do

((which_pic=$which_pic / 10))

done

# set $ update the wallpaper

gconftool-2 --type string --set /desktop/gnome/background/picture_filename ${pic[$which_pic]}

Link to comment
Share on other sites

Nice though I found it a bit easier to creat a link to the wallpaper directory and target the link with the script. Which didn't like the fact that the path way to my Wallpapers is ..../My Documents it kept on stuffing up on the space.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...