Aug 03

Configuring multiple KDE sessions to support multiple monitor configurations

Mon, 08/03/2009 - 11:36 — peter

The Problem

So, a while ago I saw in the blog of helios that there was a campaign going to raise awareness about the penumbra game trilogy - a series of games that had native linux versions - and you could get all 3 games for $5. Sounds like a good deal, right? On top of it you are also supporting a good cause, so I said "why not?" and bought the trilogy.

Now I haven't really played a PC game since, well, 2003 - before I begun using Linux 100% of the time. I have a decent quad-core AMD-based PC with a decent/recent video card in it and a dual-monitor setup, but I haven't tried to play a game in it yet - this was about to change! I downloaded the penumbra trilogy, installed it and launched the game. Guess what? My dual-monitor setup was messing up the game as about half of it was off to the right of my right-most monitor. Oh, shucks!

The Solution

Well, I remember recently talking to @brisho and he was saying how he got these 2 X sessions going: 1 for normal use and 1 for him to play "Quake Wars" (natively in linux, mind you!), so I thought "how hard can it be to set that up?" Apparently it is not hard at all! All I had to do was type the following:

startx /usr/bin/startkde -- :1

However, that gave me an error as I had to be root to get that to run - and that just wouldn't do. So, after a big of googling I found that I had to change a line in the /etc/X11/Xwrapper.config file. I am using Kubuntu Jaunty here, so I can't guarantee your file will be on the exact same location, but changes are it will. So I did the
sudo vim /etc/X11/Xwrapper.config

And changed
allowed_users=console

To
#allowed_users=console
allowed_users=anybody

Ok, that was better, but I still had to fire up nvidia-settings and reconfig my monitor setup to single monitor every time I started that X session with kde. I wondered again how hard would it be to automate this. Again, it wasn't that hard, but required a minor change on my xorg.conf file. Here is how my xorg.conf file looked before I changed anything:

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 1.0  (buildd@crested)  Sun Feb  1 20:25:37 UTC 2009
 
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 1.0  (buildmeister@builder58)  Tue Nov  4 17:18:57 PST 2008
 
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"    
EndSection                                                                      
 
Section "ServerFlags"
    Option         "Xinerama" "0"
    Option         "DontZap" "False"
EndSection                          
 
Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse" 
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"  
EndSection                               
 
Section "InputDevice"
 
        # generated from default
    Identifier     "Keyboard0"  
    Driver         "kbd"        
EndSection                      
 
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "CMO CMC 22 W"
    HorizSync       30.0 - 82.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
EndSection
 
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 8800 GT"
EndSection
 
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AddARGBGLXVisuals" "True"
    Option         "TwinView" "1"
    Option         "TwinViewXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DFP-0: nvidia-auto-select +1280+0, DFP-1: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

These names were all generated automatically by the nvidia app as I have avoided changing the xorg.conf file until now.Since the startx command lets you pass a layout name as argument, I thought I would just add another layout and monitor sections to fit what I needed. Here is the xorg.conf file after I added the Layout1 and Screen1 sections:

peter@corellia:~$ cat /etc/X11/xorg.conf
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 1.0  (buildd@crested)  Sun Feb  1 20:25:37 UTC 2009
 
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 1.0  (buildmeister@builder58)  Tue Nov  4 17:18:57 PST 2008
 
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"    
EndSection                                   
 
Section "ServerLayout"
    Identifier     "Layout1"
    Screen      0  "Screen1" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"    
EndSection                                   
 
Section "ServerFlags"
    Option         "Xinerama" "0"
    Option         "DontZap" "False"
EndSection                          
 
Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse" 
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"  
EndSection                               
 
Section "InputDevice"
 
        # generated from default
    Identifier     "Keyboard0"  
    Driver         "kbd"        
EndSection                      
 
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "CMO CMC 22 W"
    HorizSync       30.0 - 82.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
EndSection
 
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 8800 GT"
EndSection
 
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AddARGBGLXVisuals" "True"
    Option         "TwinView" "1"
    Option         "TwinViewXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DFP-0: nvidia-auto-select +1280+0, DFP-1: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
 
Section "Screen"
    Identifier     "Screen1"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AddARGBGLXVisuals" "True"
    Option         "TwinView" "1"
    Option         "TwinViewXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DFP-0: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Then to start that Xsession, I just type:

startx /usr/bin/startkde -- :1 -layout Layout1

Voila! A new xsession is started with kde and I can then reconfigure my plasmoids to my liking. Switching between both sessions is easy with ctrl-alt-f7 and ctrl-alt-f9. I may just add a k-launcher menu item with that command later, but now Penumbra runs perfectly in full-screen mode!

Easy Peasy!
-PCP