Using two monitors with X.org

Using two monitors with X.org

I recently started building up a new box
which will eventully become both a workstation and a jail server. This computer has two monitors attached and it runs
pretty good.

The hardware is:

  • AMD Phenom(tm) 9600 Quad-Core Processor (2300.91-MHz K8-class CPU)
  • 4GB RAM
  • 2x500GB SATA 3.0 drives (soon to be gmirrored)
  • Two Dell 2005FPW 1680×1050 screens
  • e-GeForce 8600 GT video card

My thanks to Christian Laursen for helping me set this up. He put me onto xrandr and the Virtual keyword.

The xorg.conf

The key section in my xorg.conf file is the Screen. I have reproduced it here.
Note the Virtual directive. The 3360 is 2 x 1680, which is the horizontal resolution of one of my monitors.
This gives us a virtual screen twice as wide as a single screen. Which is not coincidental, given I have two monitors.

Section "Screen"
    Identifier  "Screen 1"
    Device      "e-GeForce8600GT"
    Monitor     "Dell2005FPW"
    DefaultDepth 24

    Subsection "Display"
        Depth       8
        Modes       "1680x1050" "1280x1024" "1024x768" "800x600" "640x480"
        Virtual 3360 1050
        ViewPort    0 0
    EndSubsection
    Subsection "Display"
        Depth       16
        Modes       "1680x1050" "1280x1024" "1024x768" "800x600" "640x480"
        Virtual 3360 1050
        ViewPort    0 0
    EndSubsection
    Subsection "Display"
        Depth       24
        Modes       "1680x1050" "1280x1024" "1024x768" "800x600" "640x480"
        ViewPort    0 0
        Virtual 3360 1050
    EndSubsection
EndSection

At this point, both screens are set up and connected to the video card,
which has two DVI outputs. When you start X, you’ll see the same image
on both screens.

xrandr magic

Be sure to install x11/xrandr. This is a “Primitive command line
interface to the RandR extension”. See http://en.wikipedia.org/wiki/XRandR
for more information.

cd /usr/ports/x11/xrandr
make install clean

After installing, run xrandr. I saw this:

$ xrandr
Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 1680 x 1680
VGA1 disconnected
DVI0 connected 1680x1050+0+0 434mm x 270mm
   1680x1050      59.9*+
   1280x1024      75.0     59.9
   1152x864       74.8
   1024x768       75.1     60.0
   800x600        75.0     60.3
   640x480        75.0     60.0
   720x400        70.1
VGA2 disconnected
DVI1 connected 1680x1050+0+0 434mm x 270mm
   1680x1050      59.9*+
   1280x1024      75.0     59.9
   1152x864       74.8
   1024x768       75.1     60.0
   800x600        75.0     60.3
   640x480        75.0     60.0
   720x400        70.1

Now for the magic. Issue the following command:

xrandr --output DVI1 --right-of DVI0

Now you should have one large desktop and be able to move the mouse from one monitor to the other. Very nice. 🙂

Keeping the two screens every time

To invoke xrandr each time you start X, add the command to ~/.xinitrc (or
~/.xsession, whichever you are using):

xrandr --output DVI1 --right-of DVI0

I added that entry just before the call to startkde.

Here is my screen shot.

screen shot.

2 thoughts on “Using two monitors with X.org”

  1. Dan, thanks, great article. Will this work with any wm? As an aside I have done a page about TWM [www.cpcnw.co.uk/twm/] Many people dismiss it but TWM is usefull to get you into X very quickly 🙂 Perhaps it (and other lightweight WM’s) could make a good article? All the best, Graham.

    1. I just tried KDE 4.2.2 and found that the device names have changed. A ‘-‘ has been inserted. For example, I now need to do this:

      xrandr –output DVI-1 –right-of DVI-0


      The Man Behind The Curtain

Leave a Comment

Scroll to Top