I alighted on these links: https://stackoverflow.com/questions/47960344/automatically-detect-when-hdmi-is-plugged-in https://stackoverflow.com/questions/10170415/detect-when-hdmi-cable-is-plugged-in-desktop-linux?rq=1 The former got a snotty reception there, but it suggested looking at /sys.
$ cat /sys/class/drm/card0/card0-HDMI-A-1/status connected $ All well and good when the cable's connected. And if I pull the cable and the kernel vomits the EDID into /var/log/kern.log¹, then $ cat /sys/class/drm/card0/card0-HDMI-A-1/status disconnected $ Replace the cable and remove again. If the kernel remains quiet, the message stays at "connected" even though the cable is out. When in X, typing xrandr -q appears to prod things so that the status gets updated, but I want to be able to determine the status outside X: now xrandr doesn't work of course as it can't open the display. What should I prod so that I get a reliable status before starting X? ¹ The dump seems to be the result of an error presumably caused by the way in which the contacts break, leading to a checksum error: [drm:drm_edid_block_valid [drm]] *ERROR* EDID checksum is invalid, remainder is <N> where <N> is a random positive integer probably ≤ 255. Cheers, David.