How can I find the information to interact with DBus?

261 Views Asked by At

For example, searching the internet I found the following command that allows me to change the Wallpaper in KDE:

qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var allDesktops = desktops(); for (i = 0; i < allDesktops.length; i++) {d = allDesktops[i]; d.wallpaperPlugin = "org.kde.image";d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General"); d.writeConfig("Image", "file:///path/to/image.png")}'

Ok, it works and I can also use it in python using the dbus module, but if you couldn't find the solution with google or no documentation was available, is there any way to find what servicename, path, method and arguments should be used?

I've tried changing wallpapers from KDE settings with dbus-monitor active but it doesn't show anything useful... only 3 line like this:

clover@Lacia:~$ dbus-monitor 
method call time=1690707792.535464 sender=:1.20 -> destination=org.freedesktop.DBus serial=2845 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',path='/KPackage/Plasma/Wallpaper',interface='org.kde.plasma.kpackage',member='packageInstalled'"
1

There are 1 best solutions below

1
user19315471 On

It's possible to inspect various APIs using qdbusviewer tool from qt-tools package
For example, I can click on showText method to display a message.
The CLI command for the same action will be:

qdbus-qt5 org.kde.plasmashell /org/kde/osdService org.kde.osdService.showText "" "TEST!"

You can see that it's essentially the same path that's on the screenshot with "" and "TEST!" being the arguments to showText function.
This command will display a message with "TEST!" text (the first argument is an icon, empty in this case)

In your example with evaluateScript, it seems that Kwin scripting API is used.

enter image description here