Every time I reinstall a Linux distribution and try to use 2 screens (my laptop screen and an external one), I have to struggle with the Xorg configuration.
As I now installed Kubuntu 10.10, I was very pleased to see that I easily can change the configuration on the KDE System settings. But my joy was only a for short time as I figured out that Kubuntu 10.10 is not able to set the resolution of my external screen correctly. The desired resolution, 1280×1024 just is not listed. 🙁
As the file /etc/X11/xorg.conf is not existing anymore, there has to be another way. After a long search I found the tips for the solution on those 2 websites: http://reustle.tumblr.com/post/1607857706/force-screen-resolutions-on-ubuntu-10-10 and http://www.jejik.com/articles/2008/10/setting_up_dual_monitors_system-wide_with_xrandr_on_debian_lenny/
The solution is to use xrandr. A simple „xrandr“ in the terminal shows you the available devices and their resolutions:
Screen 0: minimum 320 x 200, current 2720 x 1024, maximum 8192 x 8192 VGA-0 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 0mm x 0mm 1360x768 59.8 1024x768 60.0* 800x600 60.3 56.2 848x480 60.0 640x480 59.9 59.9 680x384 119.6 119.9 512x384 120.0 400x300 120.6 112.7 320x240 120.1 LVDS connected 1440x900+1280+0 (normal left inverted right x axis y axis) 303mm x 190mm 1440x900 60.0*+ 50.0 1280x854 59.9 1280x800 59.8 1280x720 59.9 1152x768 59.8 1024x768 60.0 59.9 800x600 60.3 59.9 848x480 59.7 720x480 59.7 640x480 60.0 59.4 DVI-0 disconnected (normal left inverted right x axis y axis)
As you can see, VGA-0 does not have the correct resolution of 1280×1024.
This can now be added with those commands:
xrandr --newmode "1280x1024" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync xrandr --addmode VGA-0 "1280x1024"
To get the values for the first line, you can use this command:
cvt 1280 1024 60
Which should return something like this:
# 1280x1024 59.89 Hz (CVT 1.31M4) hsync: 63.67 kHz; pclk: 109.00 MHz Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
Just drop the first line and the „Modeline“. Also I renamed the label from „1280x1024_60.00“ to „1280×1024“.
Now you can tell the X server to use the new resolution:
xrandr --output VGA-0 --mode 1280x1024
I also had to do it for the internal screen:
xrandr --output LVDS --mode 1440x900
Now we can change to the dual screen:
xrandr --output VGA-0 --left-of LVDS
Sadly it always takes my external screen as primary. According to some websites, this can be solved when you swap the two „mode“ commands listed above, how ever it did not work for me. After some more research I found this working solution to set the internal screen as primary:
xrandr --output LVDS --primary
Sadly those changes get lost every time you restart the X server.
I did not find a way to make them permanent, so I have to execute those commands after every restart. To make my life easier, I put them into a script which gets executed automatically after I log in.
As I not always have an external screen, I made the script detecting if I have an external screen is connected. If not, it switches the (not connected) external screen off. On http://www.jejik.com/articles/2008/10/setting_up_dual_monitors_system-wide_with_xrandr_on_debian_lenny/ you can find an even better script. Mines looks like that:
#!/bin/sh xrandr | grep VGA | grep " connected " if [ $? -eq 0 ]; then # External monitor is connected xrandr --newmode "1280x1024" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync xrandr --addmode VGA-0 "1280x1024" xrandr --output LVDS --mode 1440x900 --output VGA-0 --mode 1280x1024 xrandr --output VGA-0 --left-of LVDS xrandr --output LVDS --primary else # External monitor is not connected xrandr --output LVDS --mode 1440x900 --output VGA-0 --off fi
Also when ever I plug in/out the external screen, I just run this script and my screens get set up as desired.