Calling DBus methods in Gjs / Gnome Shell

Viewed 3191

If I have a bus name, an object path, and an interface, how do I call DBus methods from Gjs (in a gnome-shell extension)?

I'm looking for the equivalent of the following python code:

import dbus
bus = dbus.SessionBus()
obj = bus.get_object("org.gnome.Caribou.Keyboard", "/org/gnome/SessionManager/EndSessionDialog")
obj.Open(0, 0, 120, dbus.Array(signature="o"))

(Note that I didn't explicitly use the interface due to some python-dbus magic, but I could have with iface = dbus.interface(obj, "org.gnome.SessionManager.EndSessionDialog"). Since I have the interface name, I'm fine with a solution that queries it. Also note that this example would be silly in Gjs, as it calls back into gnome-shell)

2 Answers
Related