Simplify trigger logic to port-only matching and improve Samsung detection

This commit is contained in:
Lago
2026-03-27 15:09:16 +01:00
parent 33e762c182
commit 37eb9e9fa0
8 changed files with 276 additions and 186 deletions
+18 -12
View File
@@ -1,22 +1,28 @@
from monitorcontrol import get_monitors
def get_monitor_info():
results = []
for monitor in get_monitors():
description = str(getattr(getattr(monitor, "vcp", None), "description", "") or str(monitor))
monitor_data = {"name": description, "input": "unavailable"}
# Set a breakpoint here to see each monitor object as it's found
m_data = {"name": "Unknown/Internal", "input": "N/A", "caps": ""}
try:
with monitor:
monitor_data["input"] = str(monitor.get_input_source())
except Exception as exc:
monitor_data["input"] = f"error: {exc}"
results.append(monitor_data)
# This is the line that was crashing; now it's protected
m_data["caps"] = monitor.get_vcp_capabilities()
m_data["input"] = str(monitor.get_input_source())
if "AW34" in m_data["caps"]:
m_data["name"] = "ALIENWARE (Target)"
elif "SAM" in m_data["caps"]:
m_data["name"] = "SAMSUNG (Trigger)"
except Exception:
# If a monitor (like the laptop screen) fails, we just skip it
continue
results.append(m_data)
return results
if __name__ == "__main__":
print("Connected monitor diagnostics:")
monitors = get_monitor_info()
for m in monitors:
print(f"Monitor: {m['name']} | Current Input: {m['input']}")
print("Searching for DDC/CI compatible monitors...")
for m in get_monitor_info():
print(f"Detected: {m['name']} | Current Input: {m['input']}")