Dual screen avec X.org : the right way

Sur mon laptop, j’ai deux écrans, l’écran par defaut LVDS (en 1280x800) et un autre en VGA (en 1024x768), jusqu’ici pour avoir un dual screen je mettais un :

SubSection "Display"
Virtual 2304 800
EndSubSection

Dans mon xorg.conf (2304 = 1280 + 1024 et 800 = max(800, 768)) et la configuration dans mon .xinitrc avec xrandr :

xrandr --output VGA --pos 1280x0 --mode 1024x768
xrandr --output LVDS --pos 0x0 --mode 1280x800
xrandr --output LVDS --left-of VGA

Ça pose quelques problèmes, par exemple quand je n’utilise pas le deuxième écran je suis obligé de commenter tout ça, il y a moyen de faire plus propre :

Section "ServerLayout"
Identifier		"Single"
Screen			"Screen0"
EndSection
Section "Screen"
Identifier "Screen0"
Device     "Card0"
Monitor    "Monitor0"
EndSection
Section "Device"
Identifier  "Card0"
Driver      "intel"
VendorName  "Intel Corporation"
BoardName   "Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
BusID       "PCI:0:2:0"
EndSection
Section "Monitor"
Identifier	"Monitor0"
Option		"Position"	"0 0"
Option		"PreferredMode" "1280x800"
EndSection
Section "ServerLayout"
Identifier		"Dual"
Screen			"Screen1"
EndSection
Section "Screen"
Identifier	"Screen1"
Device		"Card1"
Monitor		"Monitor0"
SubSection "Display"
Virtual	2304	800
EndSubSection
EndSection
Section "Device"
Identifier  "Card1"
Driver      "intel"
VendorName  "Intel Corporation"
BoardName   "Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
BusID       "PCI:0:2:0"
Option		"monitor-LVDS"	"Monitor0"
Option		"monitor-VGA"	"Monitor1"
EndSection
Section "Monitor"
Identifier	"Monitor1"
Option		"Position" "1280 0"
Option		"RighOf" "Monitor0"
Option		"PreferredMode"	"1024x768"
EndSection

Ici je spécifie deux ServerLayout : Single et Dual, je déclare les deux moniteurs avec les résolutions qui vont bien et leur place respective (VGA en 1024x768+1280+0 et LVDS en 1280x800+0+0)

Ainsi au démarrage je choisis mon layout (par défaut il prendra le premier : Single) :

startx -- -layout Dual