2

I executed this command in my Linux PC.

for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n "${con#*/card?-}: "; cat $p; done

And this is the result.

DP-1: disconnected

DP-2: connected

HDMI-A-1: connected

HDMI-A-2: disconnected

My Linux PC has two DP ports, and I connected to two monitors. One of the monitor is using adapter (from HDMI to DP)

Here I make a assumption, since one of the monitor is using adapter, so the result shows HDMI-A-1 is connected, instead of both DP are connected.

Is my assumption correct ?

Anson Tan
  • 1,256
  • 2
  • 13
  • 34

1 Answers1

0

I guess you are trying to detect if one monitor has been disconnected?

Here I make a assumption, since one of the monitor is using adapter, so the result shows HDMI-A-1 is connected, instead of both DP are connected.

Is my assumption correct ?

Most likely yes.

a) For more debugging I would run: lshw -short pickup a correct class and then do e.g. lshw -c display what is detected by the system.

b) You can also try to find the manufacturer of your device (you will probably need to install edid-decode for that):

ls /sys/class/drm/*/edid | xargs -n 1 edid-decode | grep Manufacturer:

When you unplug monitor or have a linux in virutal machine (like in my case) you will see a message: Manufacturer: @@@ Model 0 Serial Number 0

c) You can also try disconnecting the monitor with the adapter and monitor it. You can do that by monitoring the change via udevadm monitor --property.

If you are trying to create a callback in linux I recommend reading the already answered question.

tukan
  • 17,050
  • 1
  • 20
  • 48
  • I am wonder why it is not displaying both DP is connected, because both DP port on PC is connected. (although one of DP port is actually a adapter that convert HDMI to DP) – Anson Tan Nov 14 '19 at 10:55
  • @AnsonTan I would need to know more about the HDMI converter, could you post some details? I have tried it on my laptop and the converter and I got `LVDS` - connected the notebook screen and the `DP-1` (with the converter) - connected. My converter is HP original DP 1.2 to HDMI 1.4 adapter PN:778968-001 (https://www.amazon.com/HP-DisplayPort-HDMI-1-4-Adapter/dp/B00L9BCH00) so it is not always so. In your case I think the reason is the adapter you have. Could you try connecting and disconnecting the monitors? What report the monitors the same way? What monitor(s) are you connecting? – tukan Nov 14 '19 at 13:34
  • @AnsonTan What graphic card are you connecting to? – tukan Nov 14 '19 at 13:40