gconftool-2 in Intrepid not working from cron

Bug #285937 reported by mike2357
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gconf (Ubuntu)
Invalid
Low
Ubuntu Desktop Bugs

Bug Description

Binary package hint: gconf

In Hardy and prior versions, I used cron to call a script to change my screen background. In Intrepid, these commands do not work from cron, although they do work from the command line. For some reason, gconftool-2 is not attaching to my session. The script is executing fine and produces output, it's just that the gconftool-2 commands don't have any effect.

Commands:
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picture_name"
gconftool-2 -t str --set /desktop/gnome/background/picture_options "stretched"

Clue:
When the script it run from cron, the following command gives an exit status of 2, which means gconfd is not running. When run from the command line, it gives an exit status of 0, wihch means gconfd is running.
gconftool-2 --ping

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 8.10
Package: gconf2 2.24.0-0ubuntu1
ProcEnviron:
 PATH=/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: gconf
Uname: Linux 2.6.27-7-generic i686

Tags: apport-bug
Revision history for this message
mike2357 (mike2357) wrote :
Revision history for this message
gnudoc (gnudoc) wrote :

I get exactly the same result.
Some background discussion at http://ubuntuforums.org/showthread.php?t=952452

Changed in gconf:
status: New → Confirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

thank you for your bug report, that's not a bug though gconf just uses dbus now so it needs a session bus running, you can run the command using dbus-launch which should work correctly

Changed in gconf:
assignee: nobody → desktop-bugs
importance: Undecided → Low
status: Confirmed → Invalid
Revision history for this message
Loïc Minier (lool) wrote :

This is related to the move of gconf from corba to DBus.

Because gconf is now over the session dbus, you can't talk to it from cron.

There's a way around this, which is to locate one process running in your dbus session and reading the "DBUS_SESSION_BUS_ADDRESS" env var from it; for instance:
xargs -n 1 -0 echo </proc/$(pidof x-session-manager)/environ | grep -Z DBUS_SESSION_BUS_ADDRESS=

Revision history for this message
mike2357 (mike2357) wrote :

Thanks for the advice. I was able to capture DBUS_SESSION_BUS_ADDRESS. Now what do I do with it so I can call gconftool-2 from cron?

Revision history for this message
Loïc Minier (lool) wrote : Re: [Bug 285937] Re: gconftool-2 in Intrepid not working from cron

On Sun, Oct 19, 2008, mike2357 wrote:
> Thanks for the advice. I was able to capture DBUS_SESSION_BUS_ADDRESS.
> Now what do I do with it so I can call gconftool-2 from cron?

 You set it in the env of gconftool-2.

--
Loïc Minier

Revision history for this message
kraftb (kraftb) wrote :

Hi !

I think it is easier to get the DBUS_SESSION_BUS_ADDRESS from:

/home/myUser/.dbus/session-bus/

In this directory you find a list of files for each dbus (gnome?) session ...
You could either simply "source" it or otherwise add the variables in there to your environment.

Revision history for this message
Thierry Daucourt (thierry-daucourt) wrote :

adding the line below, inside the script that is launched by cron, solved my problem:

export $(xargs -n 1 -0 echo </proc/$(pidof x-session-manager)/environ | grep -Z DBUS_SESSION_BUS_ADDRESS=)

Revision history for this message
Loïc Minier (lool) wrote :

The best thing to do in your crons is to source the correct file in ~/.dbus/session-bus. The layout is $(cat /var/lib/dbus/machine-id)-$DISPLAY. You could try all displays in the case of GConf.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.