gdbus
Interact with D-Bus services
TLDR
List all names on the session bus
List all names on the system bus
Introspect an object to see its interfaces and methods
Call a method on an object with arguments
Emit a signal from an object with arguments
Monitor all messages on the session bus
SYNOPSIS
gdbus [--system | --session | --address=ADDRESS] [--verbose] COMMAND [COMMAND_OPTIONS]
Common Commands:
gdbus call [OPTIONS] BUS_NAME OBJECT_PATH INTERFACE_NAME METHOD_NAME [ARGUMENTS...]
gdbus monitor [OPTIONS] BUS_NAME
gdbus emit [OPTIONS] OBJECT_PATH INTERFACE_NAME SIGNAL_NAME [ARGUMENTS...]
gdbus introspect [OPTIONS] BUS_NAME OBJECT_PATH
PARAMETERS
--system
Connect to the system D-Bus bus.
--session
Connect to the session D-Bus bus (this is the default behavior).
--address=ADDRESS
Connect to a D-Bus daemon at a specific address instead of the default system or session bus.
--verbose
Enable verbose output, printing more details about D-Bus interactions, especially useful for debugging.
--version
Show the program's version information and exit.
--help
Show a help message and exit.
COMMAND
The specific operation to perform (e.g., call, monitor, emit, introspect, status, list-names, etc.). Each command has its own specific set of arguments and options.
[COMMAND_OPTIONS]
Options and arguments specific to the chosen COMMAND. These vary widely depending on the operation.
DESCRIPTION
gdbus is a powerful command-line utility provided by the GLib library for interacting with the D-Bus message bus. It offers a convenient interface to perform various D-Bus operations, such as calling methods on remote D-Bus objects, sending and receiving signals, and monitoring D-Bus traffic. It serves as an essential tool for debugging D-Bus services, scripting interactions with D-Bus applications, and exploring the D-Bus system. gdbus supports both the system bus and the session bus, and it can handle complex D-Bus data types using the GVariant text format. It simplifies D-Bus interactions, making them accessible without requiring direct programming in C or using lower-level D-Bus tools like dbus-send.
CAVEATS
D-Bus services and permissions: Interactions with D-Bus services are subject to D-Bus policies and permissions, which may restrict certain operations or access.
Complex arguments: When calling methods or emitting signals with structured data types, arguments must be correctly formatted according to the GVariant text format, which can be verbose and require careful escaping.
GLib dependency: gdbus is part of the GLib library; therefore, it requires GLib to be installed on the system to function.
COMMON COMMANDS
gdbus supports a variety of commands for different D-Bus operations:
- call: Call a method on a remote D-Bus object.
- monitor: Monitor all messages (method calls, signals, replies) flowing through the D-Bus bus.
- emit: Emit a D-Bus signal from the command line.
- introspect: Introspect an object on the bus to discover its interfaces, methods, signals, and properties.
- status: Show the status of the D-Bus daemon.
- list-names: List all unique bus names currently on the bus.
- name-owner: Find the unique connection name that owns a specific bus name.
ARGUMENT FORMATTING (GVARIANT)
Arguments for commands like call and emit, as well as complex data types returned by methods, are specified using the GVariant text format. This flexible format allows for representing various data types, including basic types (integers, strings, booleans), arrays, tuples, and dictionaries. For example:
- String: 'hello world'
- Unsigned 32-bit integer: uint32 42
- Boolean: true or false
- Array of strings: ['item1', 'item2', 'item3']
- Tuple: (int32 123, 'a string')
HISTORY
gdbus is part of the GLib library, a fundamental component of the GNOME desktop environment and many other Linux applications. It was introduced to provide a more consistent, higher-level, and programmatically friendly way to interact with D-Bus, especially for developers working within the GLib/GObject ecosystem. Its development aimed to simplify D-Bus integration compared to earlier, lower-level tools like dbus-send, making D-Bus interactions more robust and easier to script.
SEE ALSO
dbus-send(1), dbus-monitor(1), busctl(1), dbus-daemon(1)