How to retrieve monitors configuration from the command line?

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.


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.


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).