Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a variant dictionary (`a{sv}`) in dbus-send

Tags:

dbus

I have some trouble with dbus-send when using a{sv}

Calling a method with in_signature='a{ss}' seems to work using the following command line:

dbus-send --dest="org.test.TestService" 
/org/test/TestService/object org.test.TestService.method1 dict:string:string:"a","1","b","2"

Now I would like to have a dictionary with a variant type for values (in_signature=a{sv}),

How can I use it in dbus-send?

like image 578
camino Avatar asked Jan 13 '12 06:01

camino


People also ask

What is variant in Dbus?

A method on DBus can send or receive a Variant. This will wrap another value whose type is determined at runtime. The Variant may be parameterized to restrict the types it may accept. Constructor Summary.

What is Dbus send?

The dbus-send command is used to send a message to a D-Bus message bus. See http://www.freedesktop.org/software/dbus/ for more information about the big picture.


1 Answers

Not possible with dbus-send

As mentioned, dbus-send does not support all Dbus types. From dbus-send man page:

Also, dbus-send does not permit empty containers or nested containers (e.g. arrays of variants).


But possible gdbus

Buried in https://www.freedesktop.org/software/gstreamer-sdk/data/docs/2012.5/gio/gdbus.html we see this:

gdbus call --session \
           --dest org.freedesktop.Notifications \
           --object-path /org/freedesktop/Notifications \
           --method org.freedesktop.Notifications.Notify \
           my_app_name \
           42 \
           gtk-dialog-info \
           "The Summary" \
           "Here's the body of the notification" \
           [] \
           {} \
           5000

Bonus: this method returns the id, so you can close or replace the notification.

like image 117
André LFS Bacci Avatar answered Sep 28 '22 02:09

André LFS Bacci