How to retrieve graphic adapter & monitor name that is attached to a Xorg screen, programmatically?

StackOverflow https://stackoverflow.com/questions/15506800

  •  24-03-2022
  •  | 
  •  

Question

Obviously, this information is available in xorg.conf so I could try to parse this file. But is there a way to achieve this using Xlib calls (+ extensions) only?

Thanks, PMJ

Was it helpful?

Solution

It must be possible, because I know the program xdpyinfo can do it. At first, I was going to suggest executing that from within your program and parsing the output. That shouldn't be necessary, though, since the source of xdpyinfo is freely available.

It looks like if you have a (Display*) variable (and you will, because pretty much every X11 function call requires one), you can call these wonderful macros to get interesting data, including ServerVendor and VendorRelease. That should cover the "graphic adapter" portion of your quest.

As for the monitor name, according to xdpyinfo.c, this is governed by XF86VidModeGetMonitor() which is part of an X11 extension. This returns a XF86VidModeMonitor structure which will reveal vendor, model, and other juicy data.

Run xdpyinfo-- if that program can query the data, so can your program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top