I’m trying to use DBus example to pack a snap with client/server apps over DBus API, and of course I’m still learning DBus interface to be applied. From our doc mentioned that it provides system DBus and session DBus available, and my first problem here (sorry if my head is not clear) is, based on this example, I think it should be able to use session DBus via plugs/slots even if this snap is not for Desktop. I tried to use session as server slot first, and make sure that client’s plug is connected to server’s slot:
slots: dbus-server-slot: interface: dbus bus: session name: in.softprayog.add_server dbus-client-slot: interface: dbus bus: session name: in.softprayog.add_client plugs: dbus-server-plug: interface: dbus bus: session name: in.softprayog.add_server apps: server: command: bin/server slots: [dbus-server-slot] client: command: bin/client slots: [dbus-client-slot] plugs: [dbus-server-plug]
after server part is run, the client will report the following
$ dbus-test-snap.client Please type two numbers: 3 3 The name in.softprayog.add_server was not provided by any .service files
I’m not sure if it means that I have to put in.softprayog.add_server.service under prime/usr/share/dbus-1/services/, but even I did this it seems not to be helpful because this service was not there! (I’m using
snap run --shell to check this) Anyway using session DBus has some troubles for me.
Then, I switch to system DBus in the C code and snapcraft.yaml to have changes:
Consequently, it works with root. So another question will be: Is there a better way or an example to demonstrate how a single snap / two snaps properly works with session or system DBus? It could be important for some developers tried to deliver such snap based on original application, especially when the customer is asking.