Is there a graphical tool or maybe a command-line one that lists all the messages and parameters/arguments that I can send to a DBUS-enabled program?? I really want to try scripting some DBUS things but I can hardly find any documentation for the DBUS capabilities of most applications.
Ubuntu – Tool for viewing available DBUS messages I can send to an application
dbusgui
Related Solutions
D-Bus introduction
D-Bus provides means for communicating between services. Services can be anonymous (identified solely by bus address, like :1.6), and services can aquire well-known names, like
org.freedesktop.Notifications
ororg.freedesktop.NetworkManager
. The sender and destination which you can see in the logs are services. "Null destination" means broadcast: delivery to all services.A service can export one or several objects to the bus. Objects are given object paths, like
/org/freedesktop/NetworkManager/ActiveConnection/1
or/org/ayatana/menu/DA00003
. Object paths use slash as separator, like filesystem paths.Each object can support one or several interfaces. An interface is nothing more than a set of methods and signals, coloquially known as members (very similar to OOP interface). Methods and signals have fixed signatures. Members are always namespaced within well-known interface names.
Once published, well-known names never change.
Any service can connect to another service's signals and asynchronously call its methods. Any service can emit signals.
Signals
Now to your specific questions.
signal sender=:1.1948 -> dest=(null destination) serial=1829990 path=/org/ayatana/menu/DA00003; interface=org.ayatana.dbusmenu; member=ItemPropertyUpdated int32 23 string "enabled" variant boolean true
Yes, you're right, this is a signal. It's broadcasted by service :1.1948
, and "self" object is /org/ayatana/menu/DA00003
. The signal has name ItemPropertyUpdated
which is defined in the interface org.ayatana.dbusmenu
(like org.ayatana.dbusmenu::ItemPropertyUpdated
in C++). The serial, I guess, is a kind of unique identifier of the event on the bus.
Then we see the signal arguments. According to the interface documentation, the first int32 argument is an item's id, second string is its property name, and the third variant is the property value. So, the /org/ayatana/menu/DA00003
object is notifying us
that the item id #23 changed its enabled
property to true.
Another example on signals:
signal sender=:1.1602 -> dest=(null destination) serial=20408 path=/im/pidgin/purple/PurpleObject; interface=im.pidgin.purple.PurpleInterface; member=SendingChatMsg int32 47893 string "test" uint32 1 signal sender=:1.1602 -> dest=(null destination) serial=20409 path=/im/pidgin/purple/PurpleObject; interface=im.pidgin.purple.PurpleInterface; member=IrcSendingText int32 64170 string "PRIVMSG #chat :test
I sent a text message "test" using Pidgin to an IRC channel, and /im/pidgin/purple/PurpleObject
emitted two signals under the im.pidgin.purple.PurpleInterface
interface: first a general SendingChatMsg
, then a more specific IrcSendingText
.
Methods
Now methods. Methods are a way to ask D-Bus objects to do something, or to perform some query and return data. They are quite similar to classic OOP methods, except that D-Bus methods are called asynchronously.
Let's call a D-Bus method programmatically.
import dbus, dbus.proxies
#-- connect to the session bus (as opposed to the system bus)
session = dbus.SessionBus()
#-- create proxy object of D-Bus object
obj_proxy = dbus.proxies.ProxyObject(conn=session,
bus_name="org.freedesktop.Notifications", #-- name of the service we are retrieving object from
object_path="/org/freedesktop/Notifications") #-- the object path
#-- create proxy object of the D-Bus object wrapped into specific interface
intf_proxy = dbus.proxies.Interface(obj_proxy, "org.freedesktop.Notifications")
#-- lastly, create proxy object of the D-Bus method
method_proxy = intf_proxy.get_dbus_method("Notify")
#-- ... and call the method
method_proxy("test from python",
dbus.UInt32(0),
"bluetooth", #-- icon name
"Notification summary",
"Here goes notification body",
[], {},
5) #-- timeout
Note the arguments, especially the icon name. In your example "notification-audio-volume-medium"
was the icon of medium-powered volume speaker.
Custom services
It is absolutely possible to run your own D-Bus services, export your own D-Bus objects and define your own D-Bus interfaces with your own methods and signals. This all can be done in Python pretty easily once you grasp the overall concept and read the dbus
module documentation. :)
Calling the queue window in one double-click
Couldn't resist automating the job in a .desktop
file in a scandalously dirty hack.
Install
xdotool
sudo apt-get install xdotool
Copy the code below into an empty file, save it as
printerqueue.desktop
Then either keep it on your desktop and make it excutable, or save it in
~/.local/share/applications
To use it, double click (on your desktop) or type Printer Queue
(in Dash) to invoke the icon, and press return. Wait a few seconds (without clicking anywhere) and steps you did manually are done by the script.
The code
[Desktop Entry]
Exec=/bin/bash -c "'/usr/share/system-config-printer/system-config-printer.py' & sleep 3 && xdotool key Control_L+f"
Name=Printer Queue
Type=Application
Icon=printer
Explanation
The printers
window is called by the command:
/usr/share/system-config-printer/system-config-printer.py
If we look into the file, it seems likely that we can somehow hack it to give it the option to show the queue from cli, since the queue window is a transient (child-) window the first one.
That would be the "clean" option on one hand, but I always feel restraint to do such a thing, Even if it was only for the possible trouble during updates.
So, the "honest" dirty option then :)
Best Answer
Have you tried d-feet
Homepage