LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 01-23-2012, 07:03 AM   #1
jtsmith90
LQ Newbie
 
Registered: Jan 2012
Distribution: Ubuntu 11.10
Posts: 3

Rep: Reputation: Disabled
Script help please.


This use to work in 10.04. But i upgraded the other day and it doesnt work anymore. Is there some thing different that i have to do. No errors come up so I'm not quite sure.

Is there someone that can help me or change the code for me please.

Thanks Josh

Code:
#!/bin/bash

BACKGROUND_LOC='/home/yoda/Pictures/'          
#
###################################################################
#
### Code starts here.

## Pick new image function
pick_new_bg () {
	backgrounds=( $( < ~/.background_temp) )
	num_backgrounds=${#backgrounds[*]}
	NEW_BACKGROUND=$(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 $BACKGROUND_LOC | 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_BACKGROUND=$(/usr/bin/gconftool-2 --get /desktop/gnome/background/picture_filename | xargs basename)

while [ $NEW_BACKGROUND == $CURRENT_BACKGROUND ]
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 $BACKGROUND_LOC/$NEW_BACKGROUND

rm ~/.background_temp

# The end for this script. :(
Quote:
yoda@Jedi-Consular:~/Documents/Scripts$ ./background
yoda@Jedi-Consular:~/Documents/Scripts$
 
Old 01-23-2012, 07:36 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

I would run the following manually and see if it still works:
Code:
/usr/bin/gconftool-2 --type string --set /desktop/gnome/background/picture_filename $BACKGROUND_LOC/$NEW_BACKGROUND
Most likely, this will be where the problem is, since you are probably using unity now. Can I ask what version you upgraded to? Also, install gconf-editor, and launch the utility, and browse to that said location, and see if it even exists. You may have to research the new config location to use within your script.

Cheers,

Josh
 
Old 01-23-2012, 09:52 AM   #3
jtsmith90
LQ Newbie
 
Registered: Jan 2012
Distribution: Ubuntu 11.10
Posts: 3

Original Poster
Rep: Reputation: Disabled
Code:
/usr/bin/gconftool-2 --type string --set /desktop/gnome/background/picture_filename $BACKGROUND_LOC/$NEW_BACKGROUND
I used this but it didn't work either.


I upgraded to 11.10 still trying to get use to all the new stuff thats around. I will try gconf-editor, and launch the utility and see what i can find.

Josh
 
Old 01-23-2012, 10:07 AM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Well you understand what that does, correct? That's what I'm trying to get at - pretty much what you just said. I'm not on linux right now, so I can't look at what I need to in order to give you the right information to fix it.
 
Old 01-23-2012, 10:17 AM   #5
jtsmith90
LQ Newbie
 
Registered: Jan 2012
Distribution: Ubuntu 11.10
Posts: 3

Original Poster
Rep: Reputation: Disabled
No didn't really understand. Trying to work out were to put it in the script.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash and xterm: how make apps started by and for a script persist when script terminates porphyry5 Linux - General 4 06-15-2011 01:27 PM
[SOLVED] Script question: create a shell script in kde to log in on a server with ssh c4719929 Linux - Newbie 1 01-31-2011 03:05 AM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 08:40 AM
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 09:56 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 03:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration