X.Org/Dual Monitors
From Gentoo Linux Wiki
Getting X working on multiple monitors used to be difficult, but now it's actually quite easy!
Contents |
[edit] Per-Driver Information
The following are links to additional information about specific cards and drivers beyond the information provided below. While this information may be useful, they do not contain full information on setting up dual monitors (that's this article!)
- ATI Open-Source Driver: Install the radeon driver, then follow the general instructions on this page.
- ATI Proprietary Driver: See X.Org/Dual Monitors/ATI
- Intel: See X.Org/Dual Monitors/Intel
- Jeronimo: See X.Org/Dual Monitors/Jeronimo
- Matrox: See X.Org/Dual Monitors/Matrox
- Nvidia: See X.Org/Dual Monitors/Nvidia
- SiS: See X.Org/Dual Monitors/SiS
[edit] Single, Multi-headed Graphics Card
This should work for any driver which uses XRandR version 1.2. If you are also reading an older guide, note that it is generally not necessary to have two Driver sections in Xorg.conf for a single card.
[edit] Permanent Dual-Monitor
This method will alway start your xserver with both monitors, which is good for desktop users. In this example we'll use the open-source nouveau driver for nvidia cards.
First, we will setup your xorg.conf to gather some information about your monitors.
Section "ServerLayout"
identifier "My X Server"
screen 0 "screen0" 0 0
Endsection
...
Section "Monitor"
Identifier "Monitor0"
EndSection
...
Section "Monitor"
Identifier "Monitor1"
EndSection
...
Section "Device"
Identifier "Device0"
Driver "nouveau"
EndSection
...
Section "Screen"
Identifier "screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"
EndSubSection
EndSection
...
Now restart X, and open a terminal emulator.
Confirm that RandR is enabled:
then:
which should look something like this:
| Code: |
|
Screen 0: minimum 320 x 200, current 1280 x 1024, maximum 1280 x 1024 |
The maximum resolution of our server will be the maximum resolutions of both monitors - for two monitors that are the same as this example placed horizontally, the maximum resolution will be 2560x1024.
DVI-I-0 connected 1280x1024+0+0 (normal left inverted right x axis y axis) DVI-I-1 connected (normal left inverted right x axis y axis) </pre>}} In this example, DVI-I-0 and DVI-I-1 are the names of our outputs
Now edit xorg.conf with the information gathered.
Section "ServerLayout"
identifier "default"
screen 0 "screen0" 0 0
Endsection
Section "Monitor"
Identifier "Monitor0"
# Preferred resolution for the monitor
Option "PreferredMode" "1280x1024"
Option "Primary" "True"
EndSection
Section "Monitor"
Identifier "Monitor1"
Option "PreferredMode" "1280x1024"
Option "RightOf" "Monitor0"
Option "Primary" "False"
EndSection
Section "Device"
Identifier "Device0"
Driver "nouveau"
#assigns the output DVI-I-0 to Monitor0
Option "monitor-DVI-I-0" "Monitor0"
#assigns the output DVI-I-1 to Monitor1
Option "monitor-DVI-I-1" "Monitor1"
EndSection
Section "Screen"
Identifier "screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"
#note the lack of quotes, this line sets the 'maximum' resolution
Virtual 2560 1024
EndSubSection
EndSection
[edit] Occasional Dual-Monitors
This way is faster to set up, but requires you to set the dual screen state during each session. This is mainly used on laptops. In this example we will use the radeon driver.
Edit xorg.conf to use your driver and your primary monitor (the one that is always attached)
and add an extra large 'virtual' line
Section "ServerLayout"
identifier "default"
screen 0 "screen0" 0 0
Endsection
Section "Monitor"
Identifier "Display"
Option "Position" "0 0"
Option "PreferredMode" "1280x800"
EndSection
Section "Device"
Identifier "Displaycard"
Driver "ati"
EndSection
Section "Screen"
Identifier "screen 0"
Device "Displaycard"
Monitor "Display"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"
Virtual 4096 4096
EndSubSection
EndSection
Now restart X, and open a terminal emulator.
Confirm that RandR is enabled:
Use xrandr -q to identify the connector that the new monitor is connected to, then specify the position.
[edit] Graphical RandR tools
gnome users: system -> Preferences -> Display
and kde4 users: K -> System -> Krandr
[edit] Multiple Graphics Cards
[edit] 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:
[edit] 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: Integrated Peripherals -> Init Display First -> [PCI Slot / AGP]
- In AMIBIOS (v 08.00.08), menu: PCIPnP -> PCI Bus Scan Order -> [Ascent/Descent]
- In other BIOSs it's called: Bios First Boot -> [AGP/PCI]
[edit] 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.
... Section "Monitor" Identifier "LeftMonitor" EndSection ... Section "Monitor" Identifier "RightMonitor" EndSection ... Section "Device" Identifier "LeftCard" Driver "nvidia" EndSection ... Section "Device" Identifier "RightCard" Driver "ati" EndSection ... Section "Screen" Identifier "LeftScreen" Device "LeftCard" Monitor "LeftMonitor" DefaultDepth 24 EndSection ... Section "Screen" Identifier "RightScreen" Device "RightCard" Monitor "RightMonitor" DefaultDepth 24 EndSection ...
[edit] 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.
... Section "ServerLayout" Identifier "My X Server" Screen 0 "LeftScreen" 0 0 Screen 1 "RightScreen" RightOf "LeftScreen" EndSection
The useable keywords are "RightOf <identifier>", "LeftOf <identifier>", "Above <identifier>", and "Below <identifier>". A special keyword is "Relative" - it is used to specify the position in pixels of a screen in relation to another screen. For instance:
... Section "ServerLayout" Identifier "My X Server" Screen 0 "LeftScreen" 0 0 Screen 1 "RightScreen" Relative "LeftScreen" 1024 40 EndSection ...
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.
[edit] Using Multiple screens
With the way I have the X configuration set 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[edit] 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.
[edit] Controlling your window manager
The program x11-misc/wmctrl 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
[edit] 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:
Section "ServerFlags" Option "Xinerama" "true" EndSection
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.
USE="$USE xinerama"
[edit] Troubleshooting
- /etc/init.d/xdm stop
- 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: /etc/init.d/xdm zap
- control-alt-f7 switches to vt7 (virtual terminal), which is where X usually resides.
- control-alt-f1 (f1..f6) get to those virtual terminals
- control-alt-backspace will kill the current x session
- elinks if your x stops working, this web browser works pretty well
- You can specify a different config file to the default (/etc/X11/xorg.conf) using: startx -config <config_file>
- X can be a real pain about mice, it might not be starting because your mouse device isn't set correctly (usually /dev/input/mice)
- A second X sesssion can be started using the following command. Note that it will spawn on the next available vt (usually vt8): startx -- :1
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 (eg. 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 (including myself).
[edit] Mouse Trouble
See the Dual Monitors Mouse guide for information.