monitorcontrol icon indicating copy to clipboard operation
monitorcontrol copied to clipboard

How to identify monitors

Open x11x opened this issue 3 years ago • 5 comments

How can we identify monitors? If the order of monitors is guaranteed to be the same across reboots, we can just use its index in the get_monitors() list. I'm not sure this is the case though. On Linux the i2c bus number could change across reboots (source). I think the same is the case with HMONITOR on Windows. There is the EDID, which I believe can be parsed out into Manufacturer code, Model number and Serial number (ddcutil does this and you can use --mfg, --model and --sn flags resp. to target a specific monitor). monitorcontrol could extract either the raw EDID or some other identifying information similar to how ddcutil does it. Simply being able to sort the output of get_monitors() on some stable key and use the index should be enough for many uses (rather than trying to replicate all the features of ddcutil).

x11x avatar Mar 05 '21 05:03 x11x

At the moment there is no way to identify unique monitors, this would be a good feature to have though.

I'll accept a pull-request, but I will not be working on this for a long time, I made tons of commitments for other projects people are waiting on.

newAM avatar Mar 06 '21 16:03 newAM

Thanks, I understand. And thanks for this library. I may have a go at some point, can't at the moment though. I will need to learn a bit more about I2c and the Windows APIs. Just a few notes that may help anyone (me) trying to implement this. On Windows, we might want EnumDisplayDevices and the DeviceID member of DISPLAY_DEVICE structure, as long as there's a way to cross reference this with a HMONITOR or some other info returned by the EnumDisplayMonitors API which we are currently using. Haven't found that yet. Another possibility on Windows is WMI, apparently some monitor info can be read from there. (Either wmi python module or shelling out the wmic command line tool). On Linux, it looks like EDID can be read from the I2C bus at address 0x50.

x11x avatar Mar 08 '21 01:03 x11x

On Windows, we might want EnumDisplayDevices and the DeviceID member of DISPLAY_DEVICE structure, as long as there's a way to cross reference this with a HMONITOR or some other info returned by the EnumDisplayMonitors API which we are currently using. Haven't found that yet.

Looks promising! The "DeviceID: Not used" remark is a bit annoying, but since it is 128 bytes you're probably right to assume this is the EDID.

On Linux, it looks like EDID can be read from the I2C bus at address 0x50.

Yeah Linux is much easier in this regard, I have 3 identical monitors, and the EDID hexdump from ddcutil detect -vvv returns deterministic unique values for each monitor.

newAM avatar Mar 09 '21 00:03 newAM

Identification should be added. Currently --monitor 1 or --monitor 1 are constantly changing

hawktang avatar May 19 '22 13:05 hawktang

If your monitors are of different models or input types (dvi vs hdmi), it can be identified by the model & input field from monitor.get_vcp_capabilities().

char101 avatar Jun 07 '22 04:06 char101