How to retrieve monitors configuration from the command line?

10,111

Solution 1

This is heavily dependent on the set up of the system. One way to get the information would be if xrandr is being used:

xrandr --query

This will display something like:

Screen 0: minimum 320 x 200, current 3046 x 1050, maximum 8192 x 8192
VGA1 connected 1680x1050+1366+0 (normal left inverted right x axis y axis) 473mm x 296mm
   1680x1050      60.0*+
   1280x1024      75.0     60.0  
   1152x864       75.0  
   1024x768       75.1     60.0  
   800x600        75.0     60.3  
   640x480        75.0     60.0  
   720x400        70.1  
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 353mm x 198mm
   1366x768       60.0*+
   1360x768       59.8     60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
DP1 disconnected (normal left inverted right x axis y axis)

You could then use some text processing tool to pull out the resolution for each display.

Solution 2

You could try using the tool monitor-edid, which produces output like this

Name: DELL 2407WFP
EISA ID: DELa017
EDID version: 1.3
EDID extension blocks: 0
Screen size: 52.0 cm x 33.0 cm (24.25 inches, aspect ratio 16/10 = 1.60)
Gamma: 2.2
Digital signal
Max video bandwidth: 170 MHz

    HorizSync 30-83
    VertRefresh 56-76

    # Monitor preferred modeline (60.0 Hz vsync, 74.0 kHz hsync, ratio 16/1)
    ModeLine "1920x1200" 154 1920 1968 2000 2080 1200 1203 1209 1235 -hsyncc

This is useful if you don't want to have X running when you want to probe your monitor information.

Solution 3

xrandr only works on newer X servers with the RandR extension. Granted, that should be true of everything these days, but in case not…

xdpyinfo also prints out per-screen information, including dimension (pixel and physical size).

Share:
10,111

Related videos on Youtube

Aikanaro
Author by

Aikanaro

Updated on September 17, 2022

Comments

  • Aikanaro
    Aikanaro over 1 year

    I am making a script that needs to access the computer's monitor(s) configuration. How can I do that? Is there a command or a file I could read where I can access this information?

    At the moment, I do:

    xwininfo -root
    

    But I only have the total resolution and not the details. What I need is the resolution of each screen individually.

    • Admin
      Admin about 3 years
      When I use that I always get back xwininfo: error: unable to parse display name "" and I have no idea how to find out any display names...
  • Aikanaro
    Aikanaro over 13 years
    xdpyinfo just detects one screen in my dual-monitor configuration (with a size which is the sum of both size, same thing as xwininfo -root). Is this normal?
  • ephemient
    ephemient over 13 years
    @nbarraille: Depends on Zaphod mode. The new style setup has a single screen that all the monitors are arranged in, but the classic layout was to have a separate screen per monitor.
  • fivedogit
    fivedogit over 3 years
    It would be helpful if you explained what this package is and how to get it. Links break, as yours has.
  • jsbillings
    jsbillings over 3 years
    I’m sorry my post from over 9 years ago had a broken link. I used google and found the git repo for the tool and replaced the link. The code parses several sources, so I suggest you look at it before it disappears too.