X.Org/Dual Monitors

Getting X working on multiple monitors used to be difficult, but now it's actually quite easy!

= Rely on Auto-Detection = Modern X11 / udev can detect multiple monitors quite well. Before trying any of the below, try connecting your second monitor and restart X without an xorg.conf to see what it achieves without guidance. You will only need to follow this article if that fails.

= Additional Driver-specific Information =

The following are links to additional information about specific cards and drivers beyond the information provided below. This information may be useful if the general instructions don't achieve what you are looking for.


 * ATI Proprietary Driver (fglrx)
 * Intel
 * Jeronimo
 * Matrox
 * Nvidia
 * SiS

= Single, Multi-headed Graphics Card =

These instructions set up a single X Screen spanning two physical displays. As such, we define only one Device and one Screen in xorg.conf. This should work for any driver which uses XRandR version 1.2. Modern versions of X.Org can auto-detect most setups, so it's usually best to omit options unless absolutely necessary.

Fixed Dual-Monitors
For desktop users and other setups where the monitor configuration does not change, we start the X Server with both monitors enabled. This example shows an nVidia card using the open-source nouveau driver, and two horizontally adjacent displays with a resolution of 1280x1024.

First, we calculate the total dimensions of the X Screen. This depends on the physical placement of the two monitors and their individual resolutions. In a side-by-side arrangement, the width of the X screen equals the combined widths of the two monitors (1280+1280=2560) while the height remains unchanged. If the monitors were placed one above the other, then the width would remain the same (1280) while their heights were combined (1024+1024=2048).

In this example, our X Screen has total dimensions of 2560x1024 pixels. This figure will be used in the Virtual field when defining the screen below. Notice also how we define Monitor0 as the primary display and Monitor1 position in relation to it. Other valid position values include Left, Above, and Below.

Alternatively you can save the following to /etc/X11/xorg.conf.d/10-monitor.conf. It will use the maximum available resolution, assume Monitor0 is the primary and position Monitor1 right of Monitor0.

If X.Org does not position the displays correctly, there are a few options to help it along:

This specifies that the physical out DVI-I be used as Monitor0 and so on. Xrandr can be used to identify output ports

Occasional Dual-Monitors
If the second monitor is not always present, as in a laptop with an occasionally-used external display, we do not define a second monitor explicitly in xorg.conf, but enable it using xrandr after starting an X session. This example uses a laptop with a 1280x800 built-in display and a radeon graphics card with a VGA port.

Assuming a working single-display setup, the only necessary change is an extra large Virtual value (since we don't necessarily know how big the X Screen will be).

As always, changes to xorg.conf require restarting the X session.

After physically connecting the second screen, enable it using xrandr:

If it doesn't autoconfig to your satisfaction, identify and manually specify the screen and its position:

If you get errors, confirm that RandR is enabled:

Graphical RandR tools
Gnome users should use System -> Preferences -> Display.

KDE Users should use: K -> System -> Krandr

Other tools include:


 * -- Graphical Screen layout, orientation, resolution tool.


 * -- Basic. Allows changing resolution and enabling/disabling monitors


 * -- Buggy, but feature-rich

= Single graphics card, Multiple X screens with ZaphodHeads =

In the previous example, a single PCI device was used to stretch a screen onto two separate displays. This will demonstrate how to use a single PCI device to provide two separate screens on two separate displays. This will, for instance, allow you to launch one program on a given display with DISPLAY=:0.0, and on another with DISPLAY=:0.1.

Motivation
It is often desirable to have multiple x screens produced by a single VGA controller. Most xf86-video-* drivers support Zaphod mode, which allows for a single device to produce multiple x screens. With intel graphics integrated onto all Sandy Bridge and higher CPUs, this is especially important.

For instance, on a machine with an on-chip graphics controller, as well as a separated video card, this would allow for one display for each output.

This example will focus on intel, though it should work with radeon and nouveau drivers that support it.

Prerequisites
Your graphics driver must support Zaphod mode. For xf86-video-intel, this is available in 2.20+. You must have the appropriate kernel driver installed and loaded. You must physically have several adapter outputs on your motherboard (ex, VGA with HDMI, or HDMI with DVI, etc).

You will need to know the PCI id of your VGA controller, obtainable with

Configuration
This is a sample configuration for xf86-video-intel-2.20 on an i3, with an asus board supporting VGA, HDMI, and DVI:

None that you can determine the parameter to "ZaphodHeads" by connecting the monitors to the associated ports, starting an X session (it will clone displays by default), and running "xrandr".

Note that the 'Option     "AccelMethod"  "sna"' is required on intel chipsets in order to use ZaphodHeads. This is not well documented.

= Multiple Graphics Cards =

Prerequisites
If you are using two graphics cards it is quite quick and easy to make a new xorg.conf for your new cards. (Remember to back your current one up first!)

First, disable X from starting at boot by running:

Switching Primary Card
When you install both cards, you may find that your computer has chosen the wrong one as the primary card (the one that your bios information shows up on).

If you're using two different card interfaces, such as PCI and AGP, you may be able to switch their order in your BIOS. If not, you can always switch the cables!
 * In AWARD BIOS (v4.51PG), menu:
 * In AMIBIOS (v 08.00.08), menu:
 * In other BIOSs it's called:

ATI Crossfire
See the radeon or fglrx guide depending on your chosen driver.

Configuring X
In most cases, it is simplest to let X do as much auto-configuring as possible. To that end, use as bare-bones an xorg.conf as you can, such as the one below. Change the graphics card drivers to suit your setup.

Positioning X Screens
The layout can be specified using keywords or absolute pixel positions. In this example, "LeftScreen" is located at position 0,0 with "RightScreen" to its right.

The useable keywords are "RightOf ", "LeftOf ", "Above ", and "Below ". A special keyword is "Relative" - it is used to specify the position in pixels of a screen in relation to another screen. For instance:

So, try starting the X server using your test configuration file again. Verify that the mouse can move from screen-to-screen in a relatively intuitive manner, and that your resolution and refresh rate is right. You can then copy your configuration file overtop of your old xorg.conf.

=Using Multiple screens= With the X configuration above, you are given two separate "screens". Using multiple screens in this way gives advantages mainly in terms of speed and hardware acceleration, and in allowing different colour depths on different screens. Another advantage is that your window manager effectively runs independently on each screen, so you can have different configurations on each, or many workspaces on each screen.

The main disadvantage is that you cannot move windows between two screens unless your program has a facility for doing this internally. As well, programs cannot overlap screens or stretch over all of them.

The DISPLAY environment variable on an X Server running multiple screens has the format ":0.0". The ":0" refers to the server number, and the following digit refers to the screens (counting from zero, of course).

To make an application run on a different screen than it would normally start on, run it as, where the 1 refers to the screen number that you want it to appear on.

Moving focus between screens
Moving the mouse pointer between screens can be accomplished by dragging it over the edge of one onto the next. If you are interested in a tool to do this from the command line, read the switchscreen article.

Controlling your window manager
The program can be used manually or within scripts to change workspaces and windows on either screen. KDE in particular takes control over all available X screens. If you do not want this behaviour, read the KDE Dual Monitors guide.

=Xinerama= With Xinerama, both monitors are formed into one virtual screen. Apps can move over it, and windows can overlap. Some programs that use e.g. fullscreen may not work correctly unless they are recompiled with "xinerama" added to your USE flags.

If you want/need features that you don't get with multiple screens, you can have them by using Xinerama, but at the expense of speed and causing problems with some hardware accelerated apps.

To enable Xinerama, add the following new section to your X configuration file:

Note that both monitors must run at the same color depth, or X may not start. If one of your graphics cards is limited in memory, you can either lower the resolution on it, or lower the color depth on both monitors.

Enabling xinerama support in an application allows it to know where monitor bounderies are. E.g. in metacity (the gnome window manager), it enables better placement of newly opened windows, and keeps windows on the screen better.

=Troubleshooting=
 * If Xdm won't start because it thinks it's already running, but you know it isn't, use the following command to reset its state:
 * switches to vt7 (virtual terminal), which is where X usually resides.
 * (f1..f6) get to those virtual terminals
 * will kill the current X session
 * if your X stops working, this web browser works pretty well
 * You can specify a different config file to the default using:
 * X can be a real pain about mice; it might not be starting because your mouse device isn't set correctly (usually )
 * A second X sesssion can be started using the following command. Note that it will spawn on the next available vt (usually vt8):
 * A second X sesssion can be started using the following command. Note that it will spawn on the next available vt (usually vt8):

If you have problems with windows spanning across your dual or triple monitors, or you seem to notice that your windows don't seem to "snap" to your screens, you probably haven't compiled your favorite window manager with the xinerama USE flag (if it supports it, that is). When you compile or recompile your window manager (e.g. Gnome's Metacity) with the xinerama USE flag, your windows will only maximize to one screen. This is a small, but important, issue that people tend to overlook at first.


 * If you have trouble reading text on your TV, try reducing the resolution using . can be a useful frontend for this.

= Mouse Trouble = See the Dual Monitors Mouse guide for information.

=External links=
 * nvidia-drivers-285.05.09 Twinview Documentation

Mehrere Bildschirme