Dual monitor setup on GNU/Linux using Xinerama
Update:
A dual monitor setup is supposed to increase the productivity of a person. I wanted to go for dual monitor setup on my Toshiba Satellite A80 laptop. The layout I wanted was to run the Laptop's built-in LCD as my primary display sitting on my left side and a 21" CRT monitor as my secondary display sitting on my right. My laptop's LCD would run at 1024x768 and my CRT would run at 1600x1024. I am using Ubuntu Edgy on my laptop. My laptop uses Intel Mobile 915GM Express graphics controller. I decided to use Xinerama to achieve this.
Configuration of Xorg
The snippet from my xorg.conf
for the dual monitor setup is here.
Please note that the following is not the complete xorg.conf
.
Section "Device"
Identifier "Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller 0"
Driver "i810"
BusID "PCI:0:2:0"
Option "MonitorLayout" "CRT,LFP"
VideoRam 65536
Screen 0
Option "CacheLines" "1024"
Option "DevicePresence" "true"
EndSection
Section "Device"
Identifier "Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller 1"
Driver "i810"
BusID "PCI:0:2:0"
# Option "MonitorLayout" "CRT,LFP"
VideoRam 65536
Screen 1
Option "CacheLines" "1024"
Option "DevicePresence" "true"
EndSection
Section "Monitor"
Identifier "Laptop LCD"
Option "DPMS"
EndSection
Section "Monitor"
Identifier "External CRT"
Option "DPMS"
EndSection
Section "Screen"
Identifier "Laptop LCD"
Device "Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller 0"
Monitor "Laptop LCD"
DefaultDepth 24
SubSection "Display"
Depth 1
Modes "1024x768"
EndSubSection
SubSection "Display"
Depth 4
Modes "1024x768"
EndSubSection
SubSection "Display"
Depth 8
Modes "1024x768"
EndSubSection
SubSection "Display"
Depth 15
Modes "1024x768"
EndSubSection
SubSection "Display"
Depth 16
Modes "1024x768"
EndSubSection
SubSection "Display"
Depth 24
Modes "1024x768"
EndSubSection
EndSection
Section "Screen"
Identifier "External CRT"
Device "Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller 1"
Monitor "External CRT"
DefaultDepth 24
SubSection "Display"
Depth 1
Modes "1600x1200"
EndSubSection
SubSection "Display"
Depth 4
Modes "1600x1200"
EndSubSection
SubSection "Display"
Depth 8
Modes "1600x1200"
EndSubSection
SubSection "Display"
Depth 15
Modes "1600x1200"
EndSubSection
SubSection "Display"
Depth 16
Modes "1600x1200"
EndSubSection
SubSection "Display"
Depth 24
Modes "1600x1200"
EndSubSection
EndSection
Section "ServerLayout"
Identifier "Xinerama2M"
Screen 0 "Laptop LCD"
Screen 1 "External CRT" RightOf "Laptop LCD"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "stylus" "SendCoreEvents"
InputDevice "cursor" "SendCoreEvents"
InputDevice "eraser" "SendCoreEvents"
InputDevice "Synaptics Touchpad"
Option "Xinerama" "true"
EndSection
Switching between dual and single monitor setup
As long as I am at my desk, I can happily use my dual monitor setup. But when I am out, I will miss a display on my right. If I retain the same configuration then, the display manager is going to place windows in the missing display which would make my life difficult. Configuring the above was pretty straight forward. But having a selectable single monitor and dual monitor setup is the key for better usability. I preferred to do this selection in my Grub when I boot. Here is the way that I followed to do it.
I had two versions of xorg.conf
namely xorg.conf.1m
(the plain
old single monitor setup) and xorg.conf.xinerama2m
(the dual monitor
setup using Xinerama). Please note that you can retain both
configurations in a single file and you can select the layout during
runtime using the -layout
parameter to X
. But I didn't prefer it
as it would put me in more complications for my desired setup. The key
idea is to make xorg.conf
as a sym-link for the appropriate
configuration file for the selection. For achieving this, I had to
modify my /etc/init.d/gdm
script. The snippet of code that I have
added to the script is as follows.
# Selection of Xorg layout if grep -i "Xorg-1m" /proc/cmdline > /dev/null; then ln -sf /etc/X11/xorg.conf.1m /etc/X11/xorg.conf else ln -sf /etc/X11/xorg.conf.xinerama2m /etc/X11/xorg.conf fi
The assumption that I make here is that I would use dual monitor setup
as my default setup and I would pass a kernel command line Xorg-1m
explicitly if I want to run in a single monitor setup. So, for offering
this selection, I need to edit my /boot/grub/menu.lst
to add a new
entry for single monitor setup. The snippet of the added lines follows.
title Ubuntu, kernel 2.6.17-10-generic (SINGLE MONITOR) root (hd0,1) kernel /boot/vmlinuz-2.6.17-10-generic root=/dev/sda2 ro vga=791 splash Xorg-1m initrd /boot/initrd.img-2.6.17-10-generic quiet boot