X.Org/Dual Monitors

From Gentoo Linux Wiki

Jump to: navigation, search
Please format this article according to the Style Guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article.

Reason(s): I, me, myself and my are used.

Fix me:
  • This article refers to software versions no longer in the main package tree. It should be updated, any necessary corrections made and version numbers changed.

X.Org TOC

Based on my own experiences from using a dual-monitor setup in Gentoo for quite some time, I have decided to write a little HOWTO on how to do it, for using both Xinerama and separate screens. 3d acceleration has even been possible (if not at the best possible speeds) in both setups.

Does setting up a dualhead under linux really have to be so hard? It's so elementary!

Note: The filename xorg.conf refers to either the /etc/X11/xorg.conf or /etc/X11/XF86Config and is usually only showing a portion of the file.

Contents

[edit] Setting up Two 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.

First, of course, make sure you are using a recent version of X for best results. This article uses X.org 6.7.0.

Now backup your existing X configuration - things could go wrong, or you might need it for reference later.

Disable X from starting at boot by running:
rc-update del xdm

Then shut down your computer, insert both graphics cards, and boot the computer back up again. The screen that your bios information shows up on is your "primary" monitor. If this is the wrong one, and you are using an AGP and a PCI graphics card, there should be an option in your BIOS that lets you choose which one to use.

  • 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. It can usually detect your graphics cards, at least.

As root run:
X -configure

This will make your screen blink a few times, before returning with a message saying that it has created a test X configuration file at /root/xorg.conf.new and giving the command line to test the X server using this config file.

With a bit of luck, this should be a working X configuration. You may have to edit the mouse, monitor, or resolution settings. This is done in the same way as with a single-monitor setup, but there will be two "Monitor" sections, two "Device" sections, and two "Screen" sections. The "Screen" sections connect a monitor to a graphics card.

It is probably a good idea to change the Identifiers of the device and monitor sections so you can tell them apart, e.g.

File: xorg.conf
...
Section "Monitor"
  Identifier   "NECMonitor"
...
Section "Monitor"
  Identifier   "VSMonitor"
...
Section "Device"
  Identifier  "NvidiaCard"
  Driver      "nvidia"
...
Section "Device"
  Identifier  "AtiCard"
  Driver      "ati"
...
Section "Screen"
  Identifier   "LeftScreen"
  Device       "NvidiaCard"
  Monitor      "NecMonitor"
  DefaultDepth 24
...
Section "Screen"
  Identifier   "RightScreen"
  Device       "AtiCard"
  Monitor      "VSMonitor"
  DefaultDepth 24

At the top of the file, there is a section called "ServerLayout". This section specifies the layout of your monitors. In the above configuration, the two monitors are beside each other ("RightScreen" is to the right of "LeftScreen").

The layout can be specified using keywords or absolute pixel positions (useful for odd layouts, or even overlapping layouts!?):

File: xorg.conf
Section "ServerLayout"
  Identifier     "XFree86 Configured"
  Screen      0  "LeftScreen" 0 0
  Screen      1  "RightScreen" RightOf "LeftScreen"

"LeftScreen" is located at position 0,0 with "RightScreen" to its right.

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:

File: xorg.conf
Screen      0  "LeftScreen" 0 0
  Screen      1  "RightScreen" Relative "LeftScreen" 1024 40

In most cases, the LeftOf and RightOf keywords are what you want.

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] Setting up a dual/multi-head graphics card

[edit] XRandR 1.2 Specification

This should work for any driver which uses XRandR version 1.2

[edit] The First Way

this will alway start your xserver with both monitors, this is good for desktop users in this example we'll use the new nouveau driver

1) first setup your xorg.conf file to use the desired driver and add sections for both of you monitors

File: xorg.conf
Section "ServerLayout"
 identifier "default"
 screen 0 "screen0" 0 0
Endsection

Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Acer AL1717"
    HorizSync       30.0 - 83.0
    VertRefresh     55.0 - 75.0
    Option         "DPMS"
EndSection


Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "Acer AL1717"
    HorizSync       30.0 - 83.0
    VertRefresh     55.0 - 75.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nouveau"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 7600 GT"
    BusID          "PCI:7:0:0"
EndSection


Section "Screen"
    Identifier          "screen0"
    Device              "Device0"
    Monitor             "Monitor0"
    DefaultDepth       24

    SubSection "Display"
        Depth           24
        Modes           "1280x1024"
    EndSubSection
EndSection

and (re)start your xserver

2) open a terminal emulator and type

xrandr -v

to confirm that RandR 1.2 is enabled then enter

xrandr -q

which should look something like this:

Code:
Screen 0: minimum 320 x 200, current 1280 x 1024, maximum 1280 x 1024
DVI-I-0 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 340mm x 270mm
   1280x1024      60.0*+   75.0     75.0     60.0     60.0* 
   1280x960       60.0  
   1152x864       75.0  
   1024x768       75.0     75.1     75.0     70.1     60.0     60.0  
   896x672       120.0  
   832x624        74.6  
   800x600       130.0    120.0     72.2     75.0     75.0     60.3     60.0     56.2  
   700x525       149.5    120.0  
   640x512       150.0    120.0  
   640x480       120.0     75.0     72.8     75.0     60.0     59.9  
   720x400        70.1  
   576x432       150.0  
   512x384       150.1    140.1    120.0  
   416x312       149.3  
   400x300       144.4    150.2    120.6    112.7  
   320x240       145.6    150.0    120.1  
DVI-I-1 connected (normal left inverted right x axis y axis)
   1280x1024      60.0 +   75.0     75.0     60.0     60.0  
   1280x960       60.0  
   1152x864       75.0  
   1024x768       75.0     75.1     75.0     70.1     60.0     60.0  
   896x672       120.0  
   832x624        74.6  
   800x600       130.0    120.0     72.2     75.0     75.0     60.3     60.0     56.2  
   700x525       149.5    120.0  
   640x512       150.0    120.0  
   640x480       120.0     75.0     72.8     75.0     60.0     59.9  
   720x400        70.1  
   576x432       150.0  
   512x384       150.1    140.1    120.0  
   416x312       149.3  
   400x300       144.4    150.2    120.6    112.7  
   320x240       145.6    150.0    120.1  

{{{2}}}

note the first line:

Code:
Screen 0: minimum 320 x 200, current 1280 x 1024, maximum 1280 x 1024 

the 'maximum' resolution must the resolution of both of the monitors combined in our case 2560x1024 also note the DVI-I-0 and DVI-I-1 these are the names of our outputs

3) now armed with the needed information edit xorg.config again

File: xorg.conf
Section "ServerLayout"
 identifier "default"
 screen 0 "screen0" 0 0
Endsection

Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Acer AL1717"
    HorizSync       30.0 - 83.0
    VertRefresh     55.0 - 75.0
    Option         "DPMS"
    Option         "Position"  "0 0" #add this to your farthest right monitor
    Option         "PreferredMode"  "1280x1024" # Preferred resolution for the monitor
EndSection


Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "Acer AL1717"
    HorizSync       30.0 - 83.0
    VertRefresh     55.0 - 75.0
    Option         "DPMS"
    Option         "PreferredMode"  "1280x1024" # Preferred resolution for the monitor
    Option         "RightOf" "Monitor0" #puts this monitor to the right of Monitor0
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nouveau"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 7600 GT"
    BusID          "PCI:7:0:0"
    Option	   "monitor-DVI-I-0" "Monitor0" #assigns the output DVI-I-0 to Monitor0
    Option         "monitor-DVI-I-1" "Monitor1" #assigns the output DVI-I-1 to Monitor1
EndSection

Section "Screen"
    Identifier          "screen0"
    Device              "Device0"
    Monitor             "Monitor0"
    DefaultDepth       24

    SubSection "Display"
        Depth           24
        Modes           "1280x1024"
        Virtual          2560 1024 #note the lack of quotes, this line sets the 'maximum' resolution
    EndSubSection
EndSection

[edit] The Second Way

This way is faster but requires you to set the actual dual screen state some time during each session (useful for laptop users)

in this example we will use the radeon driver from upstream ( I don't know how long ago RandR 1.2 was put into the driver)

1) edit xorg.conf to use your driver and your primary monitor (the one hat is always attached) and add an extra large 'virtual' line

File: xorg.conf
Section "ServerLayout"
 identifier "default"
 screen 0 "screen0" 0 0
# screen 1 "screen1" rightof "screen0"
Endsection

Section "Monitor"

    Identifier     "Display"
    VendorName     "HP"
    HorizSync       30.0 - 83.0
    VertRefresh     55.0 - 75.0
    Option         "DPMS"
    Option         "Position"  "0 0"
    Option         "PreferredMode"  "1280x800"
EndSection

 
Section "Device"
    Identifier     "Device0"
    Driver         "nouveau"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 7600 GT"
    BusID          "PCI:7:0:0"
    Option	   "monitor-DVI-I-0" "Monitor0"
    Option         "monitor-DVI-I-1" "Monitor1"
EndSection


Section "Device"
    Identifier     "Displaycard"
    Driver         "ati"
    BusID          "PCI:01:05:00"
EndSection


Section "Screen"
    Identifier          "screen 0"
    Device              "Displaycard"
    Monitor             "Display"
    DefaultDepth       24

    SubSection "Display"
        Depth           24
        Modes           "1280x1024"
        Virtual          4096 4096 #some drivers have a low limit for this option, possibly due to hardware limits
    EndSubSection
EndSection

and (re)start your xserver

2) now use an randr utility to manage your external display

xrandr -q
xrandr --output VGA-0 --right-of LVDS

gnome users: system -> Preferences -> Display

and kde4 users: K -> System -> Krandr

[edit] Nvidia

See X.Org/Dual Monitors/Nvidia

[edit] ATI

See X.Org/Dual Monitors/ATI

[edit] Matrox

See X.Org/Dual Monitors/Matrox

[edit] Jeronimo

To get your Jeronimo card to work, you need to use the glint driver like this:

File: xorg.conf
...

Section "Device"
   Identifier  "Texas Instruments TVP4020 [Permedia 2] 1"
   Driver      "glint"
   BusID       "PCI:3:01:0"
   Option      "XaaNoOffscreenPixmaps"
EndSection

Section "Device"
   Identifier  "Texas Instruments TVP4020 [Permedia 2] 2"
   Driver      "glint"
   BusID       "PCI:3:05:0"
   Option      "XaaNoOffscreenPixmaps"
EndSection

...

Section "Screen"
   Identifier  "Screen 1"
   Device      "Texas Instruments TVP4020 [Permedia 2] 1"
   Monitor     "Monitor 1"
   DefaultDepth 16

 Subsection "Display"
   Depth       16
   Modes       "1024x768"
   ViewPort    0 0
 EndSubsection
EndSection

...

if you have a 4port jeronimo, repeat the device section 4 times and enumerate the identifier properly and of course for every other section too, like described above. The old jeronimo hasn't much memory so you need to minimize Depth and Modes in your screen section. Depth 16 and Modes "1024x768" works for me.

[edit] SiS

Thomas Winischhofer web page has information on how to setup dual monitors. The best way is to use the Merged Framebuffer Mode. It is possible to control the screens with x11-misc/sisctrl.

[edit] SiS 771/671 PCIE

Xinerama and cloned monitors have been confirmed possible. These are the relevant sections of /etc/X11/xorg.conf:

File: xorg.conf
Section "Device"
 Identifier  	"Device0"
 Driver      	"sis"
 VendorName  	"Silicon Integrated Systems [SiS]"
 BoardName   	"771/671 PCIE VGA Display Adapter"
 BusID		"PCI:1:0:0"
 Option 	"EnableSiSCtrl" "yes"
 Option 	"DRI" "off"
 Option 	"MergedFB" "auto"
 Option 	"MetaModes" "1280x1024-1280x800 1280x1024+800x600"
 Option 	"MergedDPI" "100 100"
EndSection

[edit] Using Multiple screens

With the way I have the X configuration set above, you are given two separate "screens". These "screens" are what the extra ".0" in your DISPLAY variable are for. To make an application run on a different screen than it would normally start on, run it as

DISPLAY=":0.1" program_name

where the 1 refers to the screen number that you want it to appear on.

The Gimp has a special feature with screens. Right-click on an image, choose "View->Move to Screen", and a dialog will pop up allowing you to move the image window to a different screen.

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.

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

One advantage is that your window manager effectively runs independently on each screen, so you can have (say) eight workspaces on one, and eight on the other.

[edit] Moving focus between screens

It is no problem to move the mouse pointer between dual head screens, if you don't mind reaching for your mouse. After searching endlessly for something to allow me to move the pointer between non-xinerama dual head screens purely from the keyboard and finding nothing, I've written a program to accomplish this:

http://unlogical.net/files/scripts/switchscreen-0.4.tar.gz

Compile it up (see comment in source) and bind it to a key in Fluxbox.

File: ~/.fluxbox/keys
# switch between groups
Mod1 Tab :PrevWindow 5
Mod1 Shift Tab :NextWindow 5

# switch between workspaces
Mod1 Up : Mod1 Down :NextWorkspace

# switch between group members
Mod1 Left :PrevTab
Mod1 Right :NextTab

# switch between screens
Mod1 End :ExecCommand /usr/local/bin/switchscreen

It uses the XTEST extension to perform a 'fake' absolute mouse pointer move. It remembers the previous pointer location so you can effortlessly switch backwards and forwards between two screens. It could do with a little more work but it's perfectly functional right now. The XWarpPointer library function didn't seem to allow moving between screens so I use XTestFakeMotionEvent instead.

It can be used with any window manager since it uses pure X11 library calls. However combined with Fluxbox and keybindings to change virtual desktops, it allows you to easily change between sixteen virtual workspaces across two heads without using the mouse at all.

David Mohr adopted the above program to work with xorg 7.4 and added a small utility to wrap the mouse cursor between two separate X screens. See dualscreen-mouse-utils for more details and to download.

xbindkeys is another way to go for other window managers than Fluxbox.

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

[edit] Disable KDE MultiHead

KDE Session Manager tries to manage all possible screens that are currently running. This default behaviour may be unwanted, e.g. using secondary screen for watching movies, therefore pure X screen is a much better solution.

To disable MultiHead in KDE, edit /usr/kde/.../share/config/kcmdisplayrc and add following:

File: /usr/kde/.../share/config/kcmdisplayrc
[X11]
disableMultihead=true

[edit] Independent Dual Head in KDE 4.2

As You know, in KDE 4.2 no longer supports independent desktops. But there is possible workaround, using secondary windows manager for secondary screen. First configure in /etc/X11/xorg.conf two separate screens. Then emerge your preffered light weight window manager (but be careful only few wm are working).

emerge -av x11-wm/icewm
[ebuild   R   ] x11-wm/icewm-1.2.30  USE="esd imlib nls spell truetype xinerama -debug -minimal" 0 kB

Now when you boot into kde4.2 you must see on primary monitor normal kde desktop and on secondary monitor X server without wm (mouse cursor have X shape). After start you can type command which start secondary wm

DISPLAY=":0.1" icewm

If all is working and secondary wm is started on secondary monitor, then you can add this command after kde start into startup directory.

echo 'DISPLAY=":0.1" icewm &' >> ~/.kde4.2/Autostart/kdestart.sh
Note: Don't forget the ampersand '&' at the end of command

[edit] Using Xinerama

If you want/need the 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:

File: xorg.conf
Section "ServerFlags"
  Option    "Xinerama" "true"
EndSection

And restart X.

The main reason that X might not start after this is problems relating to conflicting colour depths - both monitors must run at the same color depth. 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.

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.

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.

[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 Jail: How to lock your mouse in the monitor

Playing games when using a dual monitor configuration can be a pain. The problem is that the mouse would move to the other monitor while playing the game, and you would lose control of the mouse for your game. To avoid this problem, there's a small program you can use, mostly based on David Antliff's switchscreen program. The idea is simply to lock your mouse in the monitor it currently is in. The tarball for this program is available at http://www.cs.kent.ac.uk/~sm244/Jail.tar.gz . You can then simply bind a shortcut key to the program from your window manager.

[edit] Switchscreen

You might like to use the second screen for certain tasks only (eg. TV). The Problem is the same as in "Mouse Jail" described above, which means you have to run jail at startup. There is an alternative solution: configure the second Screen "far away" from the first one:

File: xorg.conf
Section "ServerLayout"

       Identifier     "double"
       Screen         0 "Screen0" 0 0
       Screen         1 "Screen1" 2000 0
       InputDevice    "Mouse0" "CorePointer"
       InputDevice    "Keyboard0" "CoreKeyboard"

EndSection

X Configured like above, prevents you from moving your mouse to the second screen. When you want to move the mouse there, use a hotkey configured on your Window Manager, which runs Switchscreen (see link above) to move the mouse on the second screen. Now you are able to view TV on my second screen for example:

DISPLAY=:0.1 xine -f test.avi

while still working on the first one.

Jail might not for you (in one case Warcraft III was lagging when Jail worked to keep the cursor in the right screen). So instead configure the screens "far away" like mentioned above in this section, and then use an adapted version of the Jail program to allow the crossing of the cursor: http://dsp.mcbf.net/releases/mouse-switchscreen-0.3b.tar.bz2 . It turns out that allowing the cursor to cross over is much easier for the computer than it is to jail the cursor. The included "mouse-switchscreen.sh" script makes it easy to toggle the feature with a keyboard shortcut. That way you can have it on by default, and turn it off quickly when starting a game.

If Screen 1 has a lower resolution than Screen 0 (e.g. TV), you can also stack screen 1 on top of screen 0:

       Screen         0 "Screen0" 0 0
       Screen         1 "Screen1" 0 0

Then you can switch to Screen 0 with switchscreen and come back to Screen 1 by moving the mouse across the bottom or right border! The mouse will still be jailed in screen 0.

Also you can configure one monitor as the side of another.

File: xorg.conf
Section "ServerLayout"

       Identifier     "double"
       Screen         0 "Screen0" 
       Screen         1 "Screen1" LeftOf "Screen0"
       InputDevice    "Mouse0" "CorePointer"
       InputDevice    "Keyboard0" "CoreKeyboard"

EndSection

When you move the mouse to the left of the screen 0 appears in the screen 1.


[edit] External links

Personal tools
In other languages