ambilight-ctl: tipi corretti per i parametri stringa (port, side, capture, drm_device)
This commit is contained in:
@@ -66,15 +66,19 @@ def main(argv):
|
||||
key, raw = argv[2], argv[3]
|
||||
if key in ("reverse",):
|
||||
value = raw.lower() in ("1", "true", "yes", "on")
|
||||
elif key == "leds":
|
||||
vtype = "b"
|
||||
elif key in ("leds", "baud"):
|
||||
value = int(raw)
|
||||
vtype = "i"
|
||||
elif key in ("port", "side", "capture", "drm_device"):
|
||||
value = str(raw)
|
||||
vtype = "s"
|
||||
else:
|
||||
value = float(raw)
|
||||
vtype = "d"
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
res = call("SetParam", GLib.Variant("(sv)", (key, GLib.Variant(
|
||||
"b" if isinstance(value, bool) else "d" if isinstance(value, float) else "i",
|
||||
value))))
|
||||
res = call("SetParam", GLib.Variant("(sv)", (key, GLib.Variant(vtype, value))))
|
||||
err = res.unpack()[0]
|
||||
if err:
|
||||
print(json.dumps({"ok": False, "error": err}))
|
||||
|
||||
Reference in New Issue
Block a user