Dbus daemon

Robert McQueen robert.mcqueen at collabora.co.uk
Thu Mar 9 04:19:32 PST 2006


Marcin wrote:
> On Thu, 09 Mar 2006 11:58:02 +0100, Ross Burton <ross at burtonini.com> wrote:
>> Most distributions start the DBus daemon in the X startup scripts so the
>> entire X session has access to the DBus session bus.  If you want it
>> started when you login at a console, you could add eval `dbus-launch` to
>> your .bash_profile I guess.
> 
> Some time ago I tried to do this in this way, but it doesn't work :) I
> have no idea why :/

Probably because this gets you a new bus every time you sign in. You
could arrange something like (totally untested shell which I just typed
into this e-mail, but you get the idea)...

if [ -f ~/.dbus-session ]; then
  source ~/.dbus-session
fi
if [ "x$DBUS_SESSION_BUS_PID" == "x" || ! kill -0 $DBUS_SESSION_BUS_PID
]; then
  dbus-launch >~/.dbus-session
  source ~/.dbus-session
fi

Problems with this approach:
1. Your session bus may never go away.
2. You need to set good permissions on .dbus-session or people can steal
your bus address and cookie, and connect to it.
3. The file should be named including the hostname to avoid confusion if
your home directory if shared between machines.
4. It's racy, two shells that log in at the same time can choose to
start two buses at the same time, and then it's up to fate which one is
"the" bus.
5. If you *do* log in to a session that starts a bus, you'll get a
seperate one.

> Marcin

Regards,
Rob


More information about the dbus mailing list