hmvp/python-tdbus

should allow inhibit of org.freedesktop.DBus.Hello on establishing connection

Closed this issue · 1 comments

I was hoping to use TDBus to connect to PulseAudio's DBus interface. Pulseaudio is weird in that, while it supports DBus' protocol, it doesn't expose itself on the system or system bus. You have to connect to a separate socket, and it doesn't implement the org.freedesktop.DBus interface.

import tdbus

sess = tdbus.SimpleDBusConnection(tdbus.DBUS_BUS_SESSION)
result = sess.call_method("/org/pulseaudio/server_lookup1", "Get", tdbus.DBUS_INTERFACE_PROPERTIES, destination="org.pulseaudio.Server", format="ss", args=("org.PulseAudio.ServerLookup1", "Address"))

pasocket = result.get_args()[0][1]
print pasocket

conn = tdbus.SimpleDBusConnection(pasocket)

Results in:

'unix:path=/run/user/1000/pulse/dbus-socket'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dbus-volume.py", line 9, in <module>
    conn = tdbus.SimpleDBusConnection(pasocket)
  File "build/bdist.linux-x86_64/egg/tdbus/connection.py", line 36, in __init__
_tdbus.Error: Method "Hello" with signature "" on interface "org.freedesktop.DBus" doesn't exist

(Note that depending on your distribution and PulseAudio settings, it may not load its DBus interface. This can be done manually by running in a shell "pacmd load-module module-dbus-protocol")

hmvp commented

The Hello is sent from the C part, it is actually sent by libdbus with the dbus_bus_register call. I am not sure that there is a valid use case where you want to connect to a bus without calling that so I am a bit hesitant to provide some changes for that. If you would really like to do this you could comment out line 1343 until and including1347 in _tdbus.c

However there might be a use case for using the library as a point to point solution which some applications like pulseaudio seem to do. I might provide some support for that.

However in looking futher it might be the case that you are using the wrong interface:
See https://stackoverflow.com/a/19472108
I assume that when you enable that module, Pulseaudio becomes available on the session or system bus. If that is what you want.