Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer

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

Name: DELL 2407WFP
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.

share|improve this answer

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|improve this answer
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? – nbarraille Jan 21 '11 at 14:32
@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. – ephemient Jan 21 '11 at 15:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.