FedeDP / Clightd

A linux bus interface that lets you change screen brightness, compute captured webcam frames brightness and change screen temperature.
GNU General Public License v3.0
82 stars 10 forks source link

GLib.Variants Invalid GVariant format string for `d(du)` #106

Closed zspher closed 9 months ago

zspher commented 1 year ago

To give context, i am trying to automate clightd with Gio.DBusProxy in python. Relevant parts of the script are as follows:

from gi.repository import GLib, Gio
clight_backlight = Gio.DBusProxy.new_for_bus_sync(
    Gio.BusType.SYSTEM,
    Gio.DBusProxyFlags.NONE,
    None,
    'org.clightd.clightd',
    '/org/clightd/clightd/Backlight2',
    'org.clightd.clightd.Backlight2',
    None)

def decrease_brightness(n: int, clight_backlight: Gio.DBusProxy):
    clight_backlight.call_sync('Raise', 
                               (GLib.Variant('d(du)', 
                                             (0.05, 
                                              GLib.Variant('(du)', (0.0, 0)))
                                             )), 
                               Gio.DBusCallFlags.NO_AUTO_START, 500, None)

decrease_brightness(5, clight_backlight)

when using GLib.Variant('d(du)', (0.5, GLib.Variant('(du)', (0.0, 0)))) - d(du), TypeError: ("Invalid GVariant format string '%s'", 'd(du)') is thrown

however when using GLib.Variant('(d(du))', (0.5, GLib.Variant('(du)', (0.0, 0)))) - (d(du)) everything in a tuple, no error is thrown

the clightd API accepts d(du) (e.g./org/clightd/clightd/Backlight2 Set) so i can't automate it with GDbus. Anyway, just going to use busctl.

FedeDP commented 10 months ago

Hi! I am not very familiar with the python dbus API unfortunately...

when using GLib.Variant('d(du)', (0.5, GLib.Variant('(du)', (0.0, 0)))) - d(du), TypeError: ("Invalid GVariant format string '%s'", > 'd(du)') is thrown however when using GLib.Variant('(d(du))', (0.5, GLib.Variant('(du)', (0.0, 0)))) - (d(du)) everything in a tuple, no error is thrown

Perhaps this is a bug in the library? I mean, busctl accepts it and the sd-bus library allows it!

zspher commented 9 months ago

yup this might be a problem with the python library