1#!/usr/bin/python3 2 3import pyudev 4import pykms 5 6card = pykms.Card() 7conns = card.connectors 8 9context = pyudev.Context() 10 11dev = pyudev.Devices.from_name(context, 'drm', 'card0') 12 13monitor = pyudev.Monitor.from_netlink(context) 14monitor.filter_by('drm') 15 16for device in iter(monitor.poll, None): 17 if 'HOTPLUG' in device: 18 print("HPD") 19 for conn in conns: 20 conn.refresh() 21 modes = conn.get_modes() 22 print(" ", conn.fullname, ["{}x{}".format(m.hdisplay, m.vdisplay) for m in modes]) 23