Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using dbus-send to call GetAll

Tags:

dbus

I tried my luck with:

  dbus-send --system --print-reply  \   
     --dest=org.freedesktop.UDisks \
      /org/freedesktop/UIDisks/devices/md0 \
      org.freedesktop.DBus.Properties.GetAll \
      string:""

If I'm using d-free and send "" as parameter to GetAll I get a long list of output

Trying the code above just gives an error:

Error org.freedesktop.DBus.Error.UnknownMethod: Method "GetAll" with signature "s" on
interface "org.freedesktop.DBus.Properties" doesn't exist

So I'm doing something wrong, but I've no idea what's wrong. I searched for a solution but did not come up with a decent solution. Maybe it's to trivial, but I have no idea....

like image 346
Friedrich Avatar asked Jul 11 '14 14:07

Friedrich


3 Answers

You need to specify interface name as a parameter to GetAll. This example works for me (I have UDisks2 instead of UDisks but otherwise it's similar):

dbus-send --system --print-reply \
   --dest=org.freedesktop.UDisks2 \ 
   /org/freedesktop/UDisks2/block_devices/loop0 
   org.freedesktop.DBus.Properties.GetAll 
   string:"org.freedesktop.UDisks2.Block"
like image 177
Andrey Sidorov Avatar answered Nov 11 '22 14:11

Andrey Sidorov


I tried my luck with:

dbus-send --system --print-reply  \   
   --dest=org.freedesktop.UDisks \
    /org/freedesktop/UIDisks/devices/md0 \
    org.freedesktop.DBus.Properties.GetAll \
    string:""

You have a typo in the object path: you put UIDisks instead of UDisks. Fixing that should fix your error.


Addressing your comment on this answer about getting all properties at once, the D-Bus specification doesn’t specify that GetAll should accept an empty string for its interface_name argument, so it’s a bug if any services do accept this. Instead, you must call GetAll once for each of the interfaces on the object.

The easiest way of doing this is to use a higher-level D-Bus utility, like gdbus or D-Feet (as you were trying). dbus-send is designed for simple, low-level interaction with D-Bus services.

$ gdbus introspect --system --dest org.freedesktop.UDisks2 --object-path /org/freedesktop/UDisks2/block_devices/sda1 --only-properties
node /org/freedesktop/UDisks2/block_devices/sda1 {
  interface org.freedesktop.UDisks2.Partition {
    properties:
      readonly u Number = 1;
      …
  };
  interface org.freedesktop.UDisks2.Filesystem {
    properties:
      readonly aay MountPoints = [b'/boot/efi'];
  };
  …
}
like image 31
Philip Withnall Avatar answered Nov 11 '22 13:11

Philip Withnall


After all this years, I finally get around this and found something. Yes, sometimes it takes some time

dbus-send --system --print-reply \--dest=org.freedesktop.UDisks2 \
/org/freedesktop/UDisks2/block_devices/sda1 \
org.freedesktop.DBus.Properties.GetAll \
string:"org.freedesktop.UDisks2.Filesystem"

Works, kind of ot get the Properties of at least the Filesystem interface.

Just took me another few hours to figure out this dbus-send stuff.

like image 32
Friedrich Avatar answered Nov 11 '22 12:11

Friedrich