Xrandr and an External Monitor on my Laptop

I have found happiness, and it is in the form of xrandr!

Please note:  This will NOT work with the fglrx ATI driver.

Using the xrandr command with the ati X driver enabled, I can enable and disable an external monitor at will on my laptop.  Currently, I am running Ubuntu Hardy 8.04.  My xrandr version is 1.2:

$ xrandr –version
Server reports RandR version 1.2

I have an old CRT sitting on my desk on the other side of my laptop from the two LCDs that are attached to my desktop computer, and have plugged the old CRT into other boxes as console monitors and the like, but mostly, it just sits there taking up space.

So, I plugged it into my laptop, after it was booted and I was logged in, and ran xrandr:

$ xrandr
Screen 0: minimum 320 x 200, current 2560 x 1024, maximum 2560 x 2048
VGA-0 connected 1280×1024+0+0 (normal left inverted right x axis y axis) 310mm x 230mm
1024×768       85.0 +   84.9     75.1
1280×1024      59.9*
800×600        84.9     85.1     75.0
640×480        84.6     75.0     60.0
720×400        70.1
LVDS connected 1280×800+1280+0 (normal left inverted right x axis y axis) 0mm x 0mm
1280×800       60.0*+   60.0
1280×768       60.0
1024×768       60.0
800×600        60.3
640×480        59.9

This tells me what monitors I have plugged in (VGA-0 and LVDS), and what resolutions they support.  Using xrandr –help or man xrandr, you can devise a command to enable or disable either monitor at will.

For instance, if I want to enable the CRT in its current position, I simply run the following command:

$ xrandr –output LVDS –mode 1280×800 –pos 1280×0 –output VGA-0  –mode 1280×1024 –pos 0×0

This sets the CRT (VGA-0) up as the left-hand monitor, starting at position 0×0, and enables the LCD (LVDS) on my laptop as a continuation of the screen from position 1280×0, and sets the resolution modes for each.  Basically, it gives me a wide desktop spanning the two monitors.

When I need to unplug the CRT because it’s hurting my eyes, or if I need to take my laptop off of my desk and use it elsewhere, then I simply issue the following command to turn it off:

$ xrandr –output VGA-0 –off

Further, I can manipulate the command to place the CRT to the right of the LCD, use an LCD instead of a CRT, place a monitor above my laptop, and a number of other things.  It can also be used in virtual machines to manipulate the desktop so that when full-screen mode is enabled, the desktop resizes itself, although configuration for this is outside the scope of this document.

Off and runnin’!

/cs

Leave a Reply