Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set/get property using dbus-send

Tags:

dbus

gdbus

I have made below sample xml and need some help in forming dbus-send command to set/get propoerty "Status". I know how to call methods, but not able to read/write property using dbus-send.

xml:

<node>
    <interface name="com.pgaur.GDBUS">
        <method name="HelloWorld">
            <arg name="greeting" direction="in" type="s"/>
            <arg name="response" direction="out" type="s"/>
        </method>
        <signal name="Notification">
            <arg name="roll_number" type="i"/>
            <arg name="name" type="s"/>
        </signal>
        <property name="Status" type="u" access="readwrite"/>
    </interface>
</node>
like image 264
Prashant Gaur Avatar asked Feb 06 '18 17:02

Prashant Gaur


1 Answers

You can Get/Set DBus properties for your DBus interface using below dbus-send commands. Replace $BUS_NAME and $OBJECT_PATH with respective names.

Get Property:

dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \
org.freedesktop.DBus.Properties.Get string:com.pgaur.GDBUS string:Status

Set Property:

dbus-send --system --dest=$BUS_NAME --print-reply $OBJECT_PATH \
 org.freedesktop.DBus.Properties.Set string:com.pgaur.GDBUS string:Status variant:uint32:10

You can read DBus specification to know more about DBus Properties.

like image 166
Ravi Avatar answered Sep 19 '22 06:09

Ravi