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

丶灬走出姿态 提交于 2019-12-03 03:27:28

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.

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.

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!