Ubuntu – how to pass a{sv} arguments to gdbus


i have problem to passing the arguments of the function in a dictionary format (string,variant); i try to run a screencast in gnome and to start the function i need to pass these asrguments:

-method name="Screencast"-
  -arg type="s" direction="in" name="file_template"/-
  -arg type="a{sv}" direction="in" name="options"/-
  -arg type="b" direction="in" name="flash"/-
  -arg type="b" direction="out" name="success"/-
  -arg type="s" direction="out" name="filename_used"/-

this is my call:

~$ gdbus call --session --dest org.gnome.Shell.Screencast --object-path /org/gnome/Shell/Screencast --method org.gnome.Shell.Screencast.Screencast "test_ %d_ %t.webm" {dict:string:variant:"draw-cursor",true,"framerate",35,pipeline,"vp8enc min_quantizer=13 max_quantizer=13 cpu-used=5 deadline=1000000 threads=%T ! queue ! webmmux"}

this is the rror output: "a{sv}": 0-33:can not parse as value of type 'a{sv}'.
error is in the syntax? thx

Best Answer

  • a{sv} should be represented like:

    "{'String': <'variant_value'>, 'String2': <'variant_value'>}"

    To figure this out I called org.freedesktop.DBus.Properties.GetAll on some object interface because that returns a{sv}.

    For example, the CreateInterface method in wpa_supplicant takes a{sv}:

    gdbus call -y -d fi.w1.wpa_supplicant1 -o /fi/w1/wpa_supplicant1 -m fi.w1.wpa_supplicant1.CreateInterface "{'Ifname': <'wlan0'>}"

    or to add multiple interfaces (a true array of string:variant):

    "{'Ifname': <'wlan0'>, 'Ifname': <'wlan1'>}"