Wallpaper script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wallpaper script
# 1  
Old 08-19-2011
Bug Wallpaper script

Have trouble picking a wallpaper. Let your computer pick for you.

Code:
 
#!/bin/bash

# (Change to your path to photos)   
 
Pictures='/home/josh/Pictures'       

## Pick new image function
pick_new_bg () {
    backgrounds=( $( < ~/.background_temp) )
    num_backgrounds=${#backgrounds[*]}
    New=$(echo -n "${backgrounds[$((RANDOM%num_backgrounds))]}")    
}

## Get and export the DBUS_SESSION_BUS_ADDRESS for crontab compatibility
nautilus_pid=$(pgrep -u $LOGNAME -n nautilus)
eval $(tr '\0' '\n' < /proc/$nautilus_pid/environ | grep '^DBUS_SESSION_BUS_ADDRESS=')
export DBUS_SESSION_BUS_ADDRESS

## Find image titles in specified directory
ls $Pictures | egrep -i ".jpg|.png" > ~/.background_temp

## Pick new background image
pick_new_bg

## Get file name of current background and ensure the new background is different
Current=$(/usr/bin/gconftool-2 --get /desktop/gnome/background/picture_filename | xargs basename)

while [ $New == $Current ]
do
    pick_new_bg
done
## Set the new background and remove the temp file
/usr/bin/gconftool-2 --type string --set /desktop/gnome/background/picture_filename $Pictures/$New

rm ~/.background_temp

Josh
# 2  
Old 08-19-2011
I see a 'nautilus' in there. Presumably this only works for Gnome?
# 3  
Old 08-19-2011
I believe so I have never tried it anywhere else.

Sorry
# 4  
Old 08-19-2011
Isn't there a "random wallpaper" setting built-in within KDE/gnome or was I dreaming?
# 5  
Old 08-19-2011
Not a problem, just important to label these things.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

Shell Script Xml file wallpaper

Hello, I have a custom background in my Fedora 14 OS. which changes every 10 mins, I was able to edit an Xml file for this purpose. The structure of the Xml file looks as follows : <!-- This animation will start at time shown above. --> <static> <duration>600.0</duration> ... (3 Replies)
Discussion started by: ajayram
3 Replies

6. Solaris

change wallpaper in CDE

I'm running Solaris 9, using the CDE gui on a SunBlade 100. I want to substitute the generic wallpapers that CDE has, with my own, i.e. my kids, dog, etc. Suggestions? Directions?? Thanks in advance. (19 Replies)
Discussion started by: antalexi
19 Replies

7. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

8. UNIX for Dummies Questions & Answers

Putting Wallpaper on the Desktop

How do I put wallpaper from the internet on the Unix desktop? For example, I want to know how to perform the same operation as "right click-> Set as Wallpaper" on a graphics on a web page, in Windows. Thanks! :rolleyes: (3 Replies)
Discussion started by: pireifej
3 Replies

9. UNIX for Dummies Questions & Answers

wallpaper anyone?

we have a UNIX workstation using 'CDE' desktop manager, i'ts kind of dull seeing the same wallpaper all over again and again and again everyday. is it possible put my own wallpaper? how? i'm sure it is not similar with windows wherein you just put your bitmap file in the windows folder or is it... (2 Replies)
Discussion started by: inquirer
2 Replies
Login or Register to Ask a Question