|
@@ -17,26 +17,28 @@ def ddc_detect():
|
17
|
17
|
if len(data) < 4:
|
18
|
18
|
continue
|
19
|
19
|
|
20
|
|
- # Display X
|
21
|
|
- num = data[0].split()
|
22
|
|
- if num[0] != "Display":
|
23
|
|
- #raise ValueError("unexpected identifier (\"{}\" != \"Display\")".format(num[0]))
|
24
|
|
- continue
|
25
|
|
- field["id"] = num[1]
|
26
|
|
-
|
27
|
|
- # Monitor: name ...
|
28
|
|
- name = data[3].split()
|
29
|
|
- if name[0] != "Monitor:":
|
30
|
|
- #raise ValueError("unexpected identifier (\"{}\" != \"Monitor:\")".format(name[0]))
|
31
|
|
- continue
|
32
|
|
- field["name"] = ' '.join(name[1:])
|
33
|
|
-
|
34
|
|
- out.append(field)
|
|
20
|
+ for d in data:
|
|
21
|
+ v = d.split()
|
|
22
|
+ if v[0] == "Display":
|
|
23
|
+ field["id"] = v[1]
|
|
24
|
+ elif (v[0] == "I2C") and (v[1] == "bus:"):
|
|
25
|
+ field["bus"] = v[2]
|
|
26
|
+ elif v[0] == "Monitor:":
|
|
27
|
+ field["name"] = ' '.join(v[1:])
|
|
28
|
+
|
|
29
|
+ # if id is not there it's an "Ivalid display"
|
|
30
|
+ if "id" in field:
|
|
31
|
+ out.append(field)
|
35
|
32
|
|
36
|
33
|
return out
|
37
|
34
|
|
38
|
35
|
def ddc_get(dev):
|
39
|
|
- r = subprocess.run(["ddcutil", "-d", str(dev), "-t", "getvcp", "10"], capture_output=True)
|
|
36
|
+ if dev.startswith("/dev/i2c-"):
|
|
37
|
+ cmd = ["ddcutil", "--skip-ddc-checks", "--bus", dev.replace("/dev/i2c-", ""), "-t", "getvcp", "10"]
|
|
38
|
+ else:
|
|
39
|
+ cmd = ["ddcutil", "-d", str(dev), "-t", "getvcp", "10"]
|
|
40
|
+
|
|
41
|
+ r = subprocess.run(cmd, capture_output=True)
|
40
|
42
|
if r.returncode != 0:
|
41
|
43
|
raise ValueError("ddcutil returned {} \"{}\"".format(r.returncode, r.stderr.decode("utf-8")))
|
42
|
44
|
|
|
@@ -51,7 +53,12 @@ def ddc_set(dev, val):
|
51
|
53
|
if (val < 0) or (val > 100):
|
52
|
54
|
raise ValueError("out of range")
|
53
|
55
|
|
54
|
|
- r = subprocess.run(["ddcutil", "-d", str(dev), "-t", "setvcp", "10", str(val)], capture_output=True)
|
|
56
|
+ if dev.startswith("/dev/i2c-"):
|
|
57
|
+ cmd = ["ddcutil", "--noverify", "--bus", dev.replace("/dev/i2c-", ""), "-t", "setvcp", "10", str(val)]
|
|
58
|
+ else:
|
|
59
|
+ cmd = ["ddcutil", "--noverify", "-d", str(dev), "-t", "setvcp", "10", str(val)]
|
|
60
|
+
|
|
61
|
+ r = subprocess.run(cmd, capture_output=True)
|
55
|
62
|
if r.returncode != 0:
|
56
|
63
|
raise ValueError("ddcutil returned {} \"{}\"".format(r.returncode, r.stderr.decode("utf-8")))
|
57
|
64
|
|