Thursday, May 28, 2009

Dual Head Display

While many mistakenly call Linux servers with dual monitors using xinetrama or twin view "dual head," few know that dual head indicates a setup different than dual monitors. A dual head system has two monitors running two separate window managers or even two separate x sessions.

Problem:
I have two monitors at work, and while I am a Mac and Linux Solutions Engineer with Staples Technology Solutions, Our ticketing system is based on the .net framework, which means that I have to run windows somehow in order to enter tickets. While we can use a terminal server for this, there are other things which are also windows only which I sometimes need to test, and so I really can't do without running 3 OSs daily. I have a Mac laptop, so that takes care of one, but I only have 1 desktop and need two more OSs. Enter VirtualBox (virtualbox.org). With VirtualBox, I am able to run a windows VM on my Linux installation (or vice versa if I wanted). Now, rather than trying to set up two seperate windows managers to run and then run virtualbox on top of one of them, I figured I would save CPU cycles by running KDE on display :0.0 and starting virtualbox directly on display :0.1 without a window manager. I also wanted this because I LOVE compiz--Especially the cube with edge flip. But, I didn't want windows disappearing when I rotated the cube (which would have happened with twinview or xinetrama), so a dual head setup seemed like the perfect solution. Getting this setup however, proved to be harder than one might think...

Solution:
First, the computer I was using was a bit old, and as a result I had a bit of trouble initially when I was trying to use an old Radeon X600 card. Supposedly it was supported by the latest ATI driver, but no such luck. I never could get it to work with the proprietary driver and since the free (as in speech) driver did not support doing dual monitors through the single DVI port (with splitter) I had problems. I work around it by robbing an NV285 card out of one of the other workstations we had lying around and I was in business. Sort of. I didn't have too much trouble configuring my xorg file using the nvidia-xconfig tool. I had to then go into my xorg.conf file and disable twinview (and xinetrama) and I was good to go. Sort of. I fired up KDE and got KDE on one monitor and a blank monitor on next to it. I could move my mouse between them. Excellent. Now to set my startup options. In case you are looking for where to set programs to run at start up in KDE, creating an executable BASH script in ~/.kde/Autostart/ will cause this bash script to be executed at login. So, I wrote this little diddy and I was all set:

compiz &
DISPLAY=":0.1" VBoxManage startvm 'Windows XP' -type gui
Well, sort of all set. Now I noticed that I was getting compiz started on both monitors, even though I did not have a WM on :0.1. With a little research, I figured out that if I edited /usr/bin/compiz edited the COMPIZ_OPTIONS variable to read "COMPIZ_OPTIONS=--replace --ignore-desktop-hints --only-current-screen", it would start on just display :0.0. You can also run "compiz.real --replace --ignore-desktop-hints --only-current-screen &" in your Autostart BASH script. Be careful because compiz may autostart on Ubuntu Jaunty 9.04, so if you start it again from an Autostart script, theings are going to get confusing. I had this problem at first. I forget how I would up stopping KDE from starting compiz at startup. I found the post on the ubuntu forms, but it's not really important. What is important is that this was the absolute wrong thing to do. After doing this, I could not type on :0.1. I could move my mouse over there and select windows, but no keyboard and compiz effects were appalingly slow. So I hit the ubuntu bug tracker and came across bug https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/173517 and bug https://bugs.launchpad.net/ubuntu/+source/desktop-effects/+bug/209229. But how to configure :0.1 to stop that annoying cube behavior? I tried selecting screen 1 in ccsm (Compiz Config Settings Manager) but this just configured compiz on display :0.0. Fortunately, I came across a forum post with a user with the same problem. He was able to resolve his issue by starting ccsm on display :0.1 and then configuring. So I tried to start ccsm on display :0.1. For the record, if you need to start any program on a different display, simply prepend "DISPLAY=":X.X" to your command. I fired up my terminal and ran "DISPLAY=":0.1"ccsm" and it hung trying to load the icons for the program becuase there was no window manager on that monitor to manage the icons. Super annoying. Finally, I edited my /etc/kde4/kdm/kdmrc file and switched which display kdm started on by changing the "StaticServers=:0" to read "StaticServers=:0.1" and restarting kdm (sudo killall kdm followed by sudo kdm). Now, if you do this, be sure to disable compiz on display :0.0 and then calling compiz.real directly using the command "DISPLAY=:0.1 compiz.real --replace --ignore-desktop-hints --only-current-screen &" otherwise, you may mess things up. After this I was able to start ccsm and configure this display so that my cube only had 1 side and no loger rotated (it was appearing as a two sided cube) For some reason some of the options were global (such as edge flip) while others were localized (like the number of sides on the cube). Whatever. I got what I needed. Anyway, after setting everything back so that it displayed correctly and windows started at login, I had what I wanted. And with both monitors running compiz effects (even though :0.1 didn't use them) I was now getting the performance I wanted out of my video card. So if you are having trouble with compiz performance with your nvidia NV285 card (or other card) and are running compiz on only one screen, try running it on both screens.

Ahhh. Much better.

Here is my xorg.conf file in case you are having trouble configuring dual head:
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 1.0 (buildd@palmer) Sun Feb 1 20:21:04 UTC 2009

# xorg.conf (X.Org X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the xorg.conf manual page.
# (Type "man xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# Note that some configuration settings that could be done previously
# in this file, now are automatically configured by the server and settings
# here are ignored.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
# sudo dpkg-reconfigure -phigh xserver-xorg

Section "ServerLayout"
Identifier "Default Layout"
Screen 0 "Screen0" 0 1024
Screen 1 "Screen1" Above "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "AllowEmptyInput" "On"
EndSection

Section "Module"
Load "dbe"
Load "extmod"
# Load "type1"
# Load "freetype"
Load "glx"
EndSection

Section "ServerFlags"
Option "Xinerama" "0"
EndSection

Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "keyboard"
EndSection

Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection

Section "Monitor"
Identifier "Configured Monitor"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "DELL 1704FPT"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 76.0
EndSection

Section "Monitor"
Identifier "Monitor1"
VendorName "Unknown"
ModelName "DELL 1704FPT"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 76.0
EndSection

#Section "Device"
# Identifier "Configured Video Device"
# Driver "nvidia"
#EndSection

Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro NVS 280 PCI-E"
BusID "PCI:1:0:0"
Screen 0
# Force one level when AC power
Option "RegistryDwords" "PowerMizerLevelAC=0x3"
#Enable overclocking
Option "Coolbits" "1"

Option "RenderAccel" "True"
Option "TripleBuffer" "True"
Option "DamageEvents" "True"
Option "NoDRI"
EndSection

Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro NVS 280 PCI-E"
BusID "PCI:1:0:0"
Screen 1
# Force one level when AC power
Option "RegistryDwords" "PowerMizerLevelAC=0x3"

#Enable overclocking
Option "Coolbits" "1"
Option "RenderAccel" "True"
Option "TripleBuffer" "True"
Option "DamageEvents" "True"
Option "NoDRI"
EndSection

Section "Screen"
Identifier "Default Screen"
Device "Configured Video Device"
Monitor "Configured Monitor"
DefaultDepth 24
EndSection

Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "TwinView" "0"
Option "TwinViewXineramaInfoOrder" "CRT-0"
Option "metamodes" "CRT-0: nvidia-auto-select +0+0"
SubSection "Display"
Depth 24
EndSubSection
EndSection

Section "Screen"
Identifier "Screen1"
Device "Device1"
Monitor "Monitor1"
DefaultDepth 24
Option "TwinView" "0"
Option "metamodes" "CRT-1: nvidia-auto-select +0+0"
SubSection "Display"
Depth 24
EndSubSection
EndSection

Section "Extensions"
Option "Composite" "Enable"
EndSection

No comments:

Post a Comment