A list of available D-Bus services
Solution 1
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
You could also use DFeet if you prefer a graphical tool (see the other answers for more GUI options).
Solution 2
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)
Solution 3
qdbusviewer
is your best friend; it allows you to send D-bus messages as well:
Solution 4
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.
Related videos on Youtube
Matthias Braun
Build a better Stack Exchange: Codidact All code I publish on Stack Overflow and other sites of the Stack Exchange network shall be licensed under the BSD 2-Clause License: Copyright Matthias Braun All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Updated on September 18, 2022Comments
-
Matthias Braun almost 2 years
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.
-
Pithikos over 9 yearsSeems broken as of 2014. It lists the services but can't send messages..
-
Rob C over 9 yearsI 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
-
user768421 about 9 yearsUpvoted. I asked a follow-up question to your answer. unix.stackexchange.com/questions/203410/…
-
don_crissti about 9 years@KhurshidAlam - I have added an answer here.
-
Louis Kröger over 7 years@Pithikos
d-feet
works as of today. -
Meow over 7 yearsI 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?
-
mivk over 7 years@sherrellbc Please consider adding
d-feet
as an answer to make it more visible -
bschlueter almost 7 yearsTo 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). -
tne about 4 yearsNeat tool recommendation; thanks! As of F31 at least note that Bash completions are loaded by default, no need to source them manually.
-
usretc over 3 yearsAs of Ubuntu 20.04, runs but doesn't list all services
-
ichabod over 2 yearsThis solution was very helpful on an embedded system that didn't have qdbus installed.
-
x-yuri over 2 yearsI wonder what are these :1.1* services...