LinuxCommandLibrary

qdbus

Communicate with D-Bus applications

TLDR

List available service names

$ qdbus
copy

List object paths for a specific service
$ qdbus [service_name]
copy

List methods, signals and properties available on a specific object
$ qdbus [service_name] /[path/to/object]
copy

Execute a specific method passing arguments and display the returned value
$ qdbus [service_name] /[path/to/object] [method_name] [argument1] [argument2]
copy

Display the current brightness value in a KDE Plasma session
$ qdbus [org.kde.Solid.PowerManagement] [/org/kde/Solid/PowerManagement/Actions/BrightnessControl] [org.kde.Solid.PowerManagement.Actions.BrightnessControl.brightness]
copy

Set a specific brightness to a KDE Plasma session
$ qdbus [org.kde.Solid.PowerManagement] [/org/kde/Solid/PowerManagement/Actions/BrightnessControl] [org.kde.Solid.PowerManagement.Actions.BrightnessControl.setBrightness] [5000]
copy

Invoke volume up shortcut in a KDE Plasma session
$ qdbus [org.kde.kglobalaccel] [/component/kmix] [invokeShortcut] "[increase_volume]"
copy

Gracefully log out and then do nothing, reboot or shut down
$ qdbus [org.kde.Shutdown] [/Shutdown] [logout|logoutAndReboot|logoutAndShutdown]
copy

SYNOPSIS

qdbus [--system | --session] [--literal] [--monitor | --help | --version]
qdbus [--system | --session] [--literal] service [path [interface [method [arguments...]]]]

PARAMETERS

--system
    Uses the system-wide D-Bus bus instead of the default session bus.

--session
    Explicitly uses the user's session D-Bus bus (this is the default behavior).

--literal
    Outputs arguments literally, without converting backslash sequences or other special characters.

--monitor
    Monitors and displays all D-Bus signals and method calls flowing through the bus.

--help
    Displays a short help message and exits.

--version
    Displays the version information for qdbus and exits.

service
    The well-known D-Bus service name (e.g., org.kde.konsole). If only this is provided, qdbus lists objects for the service.

path
    The object path within the D-Bus service (e.g., /Konsole/MainApplication). If provided with service, lists interfaces for the object.

interface
    The D-Bus interface name (e.g., org.kde.konsole.Konsole). If provided with service and path, lists methods, signals, and properties for the interface.

method
    The name of the method to invoke on the specified interface. Must be combined with service, path, and interface.

arguments...
    One or more arguments to pass to the invoked method. Arguments are space-separated.

DESCRIPTION

qdbus is a command-line utility provided by the Qt framework to interact with the D-Bus message bus. It allows users to list available D-Bus services, inspect objects and interfaces exposed by these services, and invoke methods on them. It simplifies debugging and scripting interactions with D-Bus applications, especially those built with Qt. qdbus can operate on both the system and session D-Bus buses, making it a versatile tool for various system-level and user-level D-Bus communications. It's particularly useful for exploring the D-Bus interface of applications when documentation is scarce, or for quick command-line automation. Its hierarchical approach to introspection, starting from services, then objects, and finally interfaces, makes it intuitive to navigate complex D-Bus architectures.

CAVEATS

While powerful, qdbus is part of the Qt framework and its introspection capabilities might sometimes differ slightly from other D-Bus tools. It's primarily designed for interactive exploration and scripting, not for high-performance or complex D-Bus client implementations. For very low-level D-Bus interactions or when precise message formatting is required, tools like dbus-send or direct D-Bus API programming might be preferred.

INTROSPECTION CAPABILITIES

qdbus is excellent for D-Bus introspection. By gradually providing service, path, and interface arguments, one can explore the available methods, signals, and properties of any D-Bus exposed object, making it invaluable for discovering D-Bus APIs.

METHOD INVOCATION

A primary use case for qdbus is invoking methods on D-Bus objects. This allows direct interaction with applications exposing D-Bus interfaces, enabling automation or debugging tasks directly from the command line, without needing to write dedicated client code.

HISTORY

The qdbus utility was introduced as part of the Qt 4 framework, specifically with the QtDBus module. This module provided C++ bindings for the D-Bus protocol, simplifying inter-process communication for Qt applications. qdbus emerged as a convenient command-line frontend to these capabilities, enabling developers and administrators to easily inspect and interact with Qt applications exposing D-Bus interfaces. Its development has mirrored the evolution of the Qt framework, continuously providing a robust tool for D-Bus introspection and method invocation.

SEE ALSO

Copied to clipboard