107

Is there such a thing as list of available D-Bus services? I've stumbled upon a few, like those provided by NetworkManager, Rhythmbox, Skype, HAL.

I wonder if I can find a rather complete list of provided services/interfaces.

1

6 Answers 6

131

On QT setups (short commands and clean, human readable output) you can run:

qdbus

will list list the services available on the session bus and

qdbus --system

will list list the services available on the system bus.


On any setup you can use dbus-send

dbus-send --print-reply --dest=org.freedesktop.DBus  /org/freedesktop/DBus org.freedesktop.DBus.ListNames

Just like qdbus, if --session or no message bus is specified, dbus will send to the login session message bus. So the above will list the services available on the session bus.
Use --system if you want instead to use the system wide message bus:

dbus-send --system --print-reply --dest=org.freedesktop.DBus  /org/freedesktop/DBus org.freedesktop.DBus.ListNames
6
  • 1
    @don-crissti how to the to list all object-paths under a service with dbus-send or gdbus? Commented Jan 8, 2015 at 9:06
  • 1
    @KhurshidAlam - I have added an answer here. Commented May 15, 2015 at 23:06
  • DFeet has been discontinued but there's an alternative called D-Spy. Commented Nov 11, 2023 at 3:52
  • @DavidFerenczyRogožan - you should put that in an answer (with a couple of screenshots maybe...). I haven't been using gnome in years, I'll remove the D-Feet reference from my answer. Commented Nov 11, 2023 at 14:41
  • Note that you can also use qdbus to list possible paths, for example qdbus org.xfce.Thunar; and you can also list methods for given service and path, for example qdbus org.xfce.Thunar /org/xfce/FileManager. Commented Feb 20 at 13:53
49

With Python it can be simpler.

System services:

import dbus
for service in dbus.SystemBus().list_names():
    print(service)

Session services:

import dbus
for service in dbus.SessionBus().list_names():
    print(service)
5
  • Upvoted. I asked a follow-up question to your answer. unix.stackexchange.com/questions/203410/…
    – user768421
    Commented May 15, 2015 at 1:58
  • I have a question, in a Plasma 5 desktop environment, the service org.kde.Spectacle is used for taking screenshot (and it's working), but it is neither listed in system bus nor session bus, why is that?
    – Meow
    Commented Nov 1, 2016 at 12:20
  • To help those who may be looking: for at least python 2.7.13 and 3.6, the package needed for this is dbus-python, installable with pip install dbus-python. The python-dbus package is also available (I was unable to get in working in the 2 minutes I tried).
    – Schlueter
    Commented Aug 30, 2017 at 5:09
  • This solution was very helpful on an embedded system that didn't have qdbus installed.
    – ichabod
    Commented Nov 2, 2021 at 16:31
  • Another follow-up question; from dbus-python, is it possible to subscribe to when the list of available buses is updated?
    – htellez
    Commented Jun 4 at 19:39
35

qdbusviewer is your best friend; it allows you to send D-bus messages as well:

qdbusviewer showing the Session Bus tab with three subpanels

8
  • Seems broken as of 2014. It lists the services but can't send messages..
    – Pithikos
    Commented Nov 6, 2014 at 15:49
  • 6
    I can't even start it on Ubuntu 14.04. It fails with: qdbusviewer: could not exec '/usr/lib/i386-linux-gnu/qt4/bin/qdbusviewer': No such file or directory
    – kasperd
    Commented Dec 28, 2014 at 23:54
  • 7
    @Pithikos d-feet works as of today.
    – sherrellbc
    Commented Oct 24, 2016 at 7:37
  • 3
    @sherrellbc Please consider adding d-feet as an answer to make it more visible
    – mivk
    Commented Feb 12, 2017 at 14:18
  • As of Ubuntu 20.04, runs but doesn't list all services
    – usretc
    Commented Jan 3, 2021 at 11:04
21

gdbus is part of glib2 and supports Bash completions. Here is how to use it (on Fedora):

bash-4.4$ source /usr/share/bash-completion/completions/gdbus
bash-4.4$ gdbus call --system --dest <TAB><TAB>

This will show all possible destinations. To get a list of the available interfaces DBus exports the org.freedesktop.DBus.ListNames method. You can call it by running:

gdbus call --system --dest org.freedesktop.DBus \
           --object-path /org/freedesktop/DBus  \
           --method org.freedesktop.DBus.ListNames

Unfortunately this leads to unreadable output. Fortunately the output is valid python, so this is possible:

gdbus call --system --dest org.freedesktop.DBus      \
           --object-path /org/freedesktop/DBus       \
           --method org.freedesktop.DBus.ListNames | \
    python -c 'import sys, pprint; pprint.pprint(eval(sys.stdin.read()))'

I don't usually do this, but is a nice trick to keep on sleeve. I use gdbus for introspecting and proving concepts before moving to code. The bash completion saves a lot of typing and avoid typos. Would be nice to have gdbus displaying a nicer output.

1
  • 1
    Neat tool recommendation; thanks! As of F31 at least note that Bash completions are loaded by default, no need to source them manually.
    – tne
    Commented Apr 19, 2020 at 8:08
16

I prefer busctl.
Note that unlike other tools like qdbus and dbus-send this one defaults to the --system bus so to communicate with the session manager you have to explicitly use the --user switch. Also, the list command is the default operation if no command is specified so

busctl

is the same as

busctl list --system

or

# busctl list
NAME                                             PID PROCESS         USER             CONNECTION    UNIT                                                               SESSION DESCRIPTION
:1.0                                             162 systemd-timesyn systemd-timesync :1.0          systemd-timesyncd.service                                          -       -          
:1.1                                             157 systemd-network systemd-network  :1.1          systemd-networkd.service                                           -       -          
:1.10                                            199 phosphor-dump-m root             :1.10         obmc-dump-monitor.service                                          -       -          
:1.11                                            216 fru-device      root             :1.11         xyz.openbmc_project.FruDevice.service         
...

and after you can see the tree for each one

# busctl tree :1.0
`-/org
  `-/org/freedesktop
    |-/org/freedesktop/LogControl1
    `-/org/freedesktop/timesync1
1
  • busctl is definitely the way to go for all distros that default to systemd. Commented Feb 20 at 13:58
1

I would recommend also dasbus

from dasbus.connection import SystemMessageBus

bus = SystemMessageBus()
busproxy = bus.proxy
for i in sorted(busproxy.ListNames()):
    print(i)

(Substitute SessionMessageBus for the session bus.)

From the shell, on systemd systems there is busctl

busctl list

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .