Gio.bus_get_sync

function bus_get_sync(bus_type: Gio.BusType, cancellable: Gio.Cancellable): Gio.DBusConnection {
    // Gjs wrapper for g_bus_get_sync()
}
  

Synchronously connects to the message bus specified by bus_type. Note that the returned object may shared with other callers, e.g. if two separate parts of a process calls this function with the same bus_type, they will share the same object.

This is a synchronous failable function. See Gio.bus_get and Gio.bus_get_finish for the asynchronous version.

The returned object is a singleton, that is, shared with other callers of Gio.bus_get and Gio.bus_get_sync for bus_type. In the event that you need a private message bus connection, use Gio.dbus_address_get_for_bus_sync and Gio.DBusConnection.new_for_address.

Note that the returned Gio.DBusConnection object will (usually) have the Gio.DBusConnection.exit_on_close property set to true.

Since 2.26

bus_type

a Gio.BusType

cancellable

a Gio.Cancellable or null

Returns

a Gio.DBusConnection or null if @error is set. Free with GObject.Object.prototype.unref.