Enhance Samsung monitor detection logic and add unit tests for trigger candidate selection

This commit is contained in:
Lago
2026-03-27 15:16:56 +01:00
parent 37eb9e9fa0
commit c06799f7b9
3 changed files with 88 additions and 28 deletions
+6 -27
View File
@@ -1,28 +1,7 @@
from monitorcontrol import get_monitors
from monitorcontrol import get_monitors, InputSource
def get_monitor_info():
results = []
for monitor in get_monitors():
# 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:
# 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("Searching for DDC/CI compatible monitors...")
for m in get_monitor_info():
print(f"Detected: {m['name']} | Current Input: {m['input']}")
for monitor in get_monitors():
with monitor:
print(monitor.vcp.description)
input_source_raw: int = monitor.get_input_source()
print(InputSource(input_source_raw).name)