Gio.DBusConnection.prototype.signal_subscribe

function signal_subscribe(sender: String, interface_name: String, member: String, object_path: String, arg0: String, flags: Gio.DBusSignalFlags, callback: Gio.DBusSignalCallback): Number(guint) {
    // Gjs wrapper for g_dbus_connection_signal_subscribe()
}
  

Subscribes to signals on connection and invokes callback with a whenever the signal is received. Note that callback will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from.

If connection is not a message bus connection, sender must be null.

If sender is a well-known name note that callback is invoked with the unique name for the owner of sender, not the well-known name as one would expect. This is because the message bus rewrites the name. As such, to avoid certain race conditions, users should be tracking the name owner of the well-known name and use that when processing the received signal.

If one of Gio.DBusSignalFlags.match_arg0_namespace or Gio.DBusSignalFlags.match_arg0_path are given, arg0 is interpreted as part of a namespace or path. The first argument of a signal is matched against that part as specified by D-Bus.

Since 2.26

sender

sender name to match on (unique or well-known name) or null to listen from all senders

interface_name

D-Bus interface name to match on or null to match on all interfaces

member

D-Bus signal name to match on or null to match on all signals

object_path

object path to match on or null to match on all object paths

arg0

contents of first string argument to match on or null to match on all kinds of arguments

flags

flags describing how to subscribe to the signal (currently unused)

callback

callback to invoke when there is a signal matching the requested data

Returns

a subscription identifier that can be used with Gio.DBusConnection.prototype.signal_unsubscribe