Hi there,
I was trying to set the wallpaper too using gconftool-2. It was working when using a console inside GDM, but not from an ssh session or from cron. That is when I found your thread.
I got it working, but thought I should add that there is nothing wrong with the way you were doing it before and that there is no need to go checking nautilus, although it is also a perfectly valid method. With the original method, you do have the option of choosing which deisplay you wish to do this for, although this basic script assumes :0.0
The only problem was in the implementation of your script.
Try this instead...
Old code:
Code:
# Get dbus session for gconftool-2
ON_USER=$(cat /etc/passwd | grep :1000: | cut -d ':' -f 1)
Not sure why you specifically wanted the user with group id or user id of 1000, so I just will use the current user instead
Old code:
Code:
export DBUS_SESSION=$(grep -v "^#" /home/$USER/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0)
2 probs with this. First, the environment variable should be called DBUS_SESSION_BUS_ADDRESS and secondly you are setting the variable to three lines of text like this:
Code:
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-45v55v4v65,guid=a7857635b8778c78623f89723e986b82
DBUS_SESSION_BUS_PID=34377
DBUS_SESSION_BUS_WINDOWID=4121785
New code:
Code:
export DBUS_SESSION_BUS_ADDRESS=$(grep "^DBUS_SESSION_BUS_ADDRESS=" /home/$USER/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0 |cut -d'=' -f2-)
Note that this only works if the user is logged in to gnome using display :0.0
The rest was fine except the username and the environment variable setting. Alternatively, sudo is not really needed assuming you are running all of this under the same user that you are trying to change the background for.
Old code:
Code:
# start of gconftool command and set the desktop
sudo -u $ON_USER $DBUS_SESSION /usr/bin/gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomfile"
New code:
Code:
# start of gconftool command and set the desktop
/usr/bin/gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomfile"
So, concicely...
Code:
export DBUS_SESSION_BUS_ADDRESS=$(grep "^DBUS_SESSION_BUS_ADDRESS=" /home/$USER/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0 |cut -d'=' -f2-)
# start of gconftool command and set the desktop
/usr/bin/gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomfile"
Hope this helps.
Tom...
Bookmarks