Question on C code - any programmatic way of settingDBUS_BUS_SESSION address?

Andrejus Chaliapinas a.chaliapinas at
Wed Apr 23 04:48:49 PDT 2008

> If you want to connect to a bus at a non-standard address, you shouldn't
> be using "the" shared session-bus connection as returned by dbus_bus_get.
> dbus_bus_get sets up and returns a shared connection - just because *you*
> want to connect to a non-standard address for the session bus doesn't mean
> that any other libraries or components in your process want to do the
> same.

Yes, I understand that. That's why using 'export
DBUS_SESSION_BUS_ADDRESS=<non-standard address>' works for all such
specifics components started separatedly via shell scripts. Those components
actually use dbus_bus_get_private call.

> For a bus at a non-standard location, instead of calling dbus_bus_get(),
> use
> dbus_connection_open() (or possibly dbus_connection_open_private())
> followed
> by dbus_bus_register().

Well, my question was exactly related to that. Why do I need to deal with
some internals (dbus_connection_open, dbus_bus_register, etc.) instead of
having dbus_bus_get_private_by_address, which will do that all for me?

> If you really do want to manipulate the global state of your process
> (this is only appropriate if you are writing the program, rather than a
> library), manipulate the environment before any D-Bus API is called
> (e.g. in main() or in a wrapper script).

I'll try to see what could be done around that.

Thank you,

More information about the dbus mailing list