fix: use monitor.vcp.set_vcp_feature (monitorcontrol v4 API), fix monitor indices 1+2

This commit is contained in:
Miłosz Matysiak
2026-04-09 10:25:21 +02:00
parent 05a96e29e4
commit 5dcdfa5221
4 changed files with 31 additions and 17 deletions

View File

@@ -29,7 +29,7 @@ class MonitorSwitcher:
continue
try:
with monitors[idx] as monitor:
monitor.set_vcp_feature(VCP_INPUT_SOURCE, vcp_value)
monitor.vcp.set_vcp_feature(VCP_INPUT_SOURCE, vcp_value)
logger.info("Monitor %d -> VCP input %d", idx, vcp_value)
except Exception as exc:
logger.warning("Monitor %d DDC/CI error: %s", idx, exc)
@@ -46,8 +46,8 @@ class MonitorSwitcher:
for idx, monitor_handle in enumerate(get_monitors()):
try:
with monitor_handle as monitor:
current = monitor.get_vcp_feature(VCP_INPUT_SOURCE)
result.append({"index": idx, "current_vcp": current.value})
current = monitor.vcp.get_vcp_feature(VCP_INPUT_SOURCE)
result.append({"index": idx, "current_vcp": current[0]})
except Exception as exc:
logger.warning("Cannot query monitor %d: %s", idx, exc)
result.append({"index": idx, "current_vcp": None})