15

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?

Philip Withnall
  • 5,293
  • 14
  • 28
camino
  • 10,085
  • 20
  • 64
  • 115

4 Answers4

20

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.

  • 1
    André, downvoting this because the example is not for sending a `(a{sv})` argument. And that is what the question is all about because for trivial arguments, `dbus-send` is enough. – mmoya Sep 02 '17 at 11:30
  • 4
    [This answer](https://askubuntu.com/a/359944) explains the syntax of `a{sv}` arguments to `gdbus`: "{'String': <'variant_value'>, 'String2': <'variant_value'>}" – user2804197 Oct 06 '17 at 12:09
11

Although D-Bus supports signatures such as a{sv}, dbus-send does not. This is from the dbus-send man page:

"...D-Bus supports more types than these, but dbus-send currently does not. Also, dbus-send does not permit empty containers or nested containers (e.g. arrays of variants)."

So as far as I can understand it, you cannot send a dict of string:variant using dbus-send.

JoGr
  • 1,457
  • 11
  • 22
2

You need to compile dbus-send with the following patch.

https://chromium-review.googlesource.com/#/c/12323/2/sys-apps/dbus/files/dbus-1.4.12-send-variant-dict.patch

FYR, I uploaded the patched full source at this link.

https://gitlab.com/mujicion/dbus-send.git

mujicion
  • 29
  • 1
  • 2
    You might be able to improve your post by specifying **how** to apply the patch. – randers May 06 '16 at 09:25
  • Putting a random patch somewhere on the internet without submitting it to the upstream D-Bus project benefits very few people. Please do not promote this kind of answer unless the patch has also been submitted, reviewed and accepted upstream. – Philip Withnall Jul 05 '17 at 10:31
0

I compiled the new version of dbus-send but still has an issue for sending a{sv}.Can you pl provide the syntax for this