2

What is the suggested way to get information on all available monitors in Linux? For example, if I have a dual monitor setup, I'd like to find out whether the second monitor extends the first one to the right, to the left, to the bottom, or to the top. Thus, I'm ultimately looking for an API that gives me something like this if the second monitor extends the first one to the right:

Monitor #1: X=0, Y=0, Width=1920, Height=1080
Monitor #2: X=1920, Y=0, Width=1920, Height=1080

Or this if the 2nd monitor extends the 1st one to the left I want to get this:

Monitor #1: X=0, Y=0, Width=1920, Height=1080
Monitor #2: X=-1920, Y=0, Width=1920, Height=1080

On Windows I can easily get this information using EnumDisplayMonitors(). But I don't see any suitable APIs on Linux. I've already checked out XF86VidMode and RandR. XF86VidMode doesn't seem to support multi-monitor setups and RandR seems to have barely any documentation. I've also scanned through the C header files of RandR and although RandR seems to be able to collect information about all available monitors, I haven't seen an API that could give me information about how the monitors are aligned to form one large screen.

Am I missing something here or is this generally not possible on Linux?

Thanks for any hints!

3
  • 2
    Have you tried XineramaQueryScreens ? Commented Jun 9, 2014 at 14:40
  • No, thanks for the pointer! This seems to be what I want.
    – Andreas
    Commented Jun 9, 2014 at 15:38
  • LibXinerama works fine but I've just found out that it's also possible to get this information from the XRandR extension: It's in the XRRCrtcInfo structure returned by XRRGetCrtcInfo().
    – Andreas
    Commented Jun 10, 2014 at 15:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.