Files
KVM_Switch/monitorcontrol_main.py
T

28 lines
1.1 KiB
Python

from monitorcontrol import get_monitors
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']}")