Nvidia twinview and xrandr

AJ, I agree that GUI tools for multihead are lacking. I recently got my nvidia twinview working much easier with some fiddling.

Inspired by smcv’s setup, I also have my external monitor above my laptop screen, and it’s only slightly wider than the laptop screen so I run them at the same width. Since my laptop has an Nvidia Geforce Go 6200, I’ve generally used nvidia-settings to set twinview mode on and off. Since that’s a GUI app, I’ve had to click several times to turn twinview on and off. Turning twinview off automatically moves all the windows to my laptop display, and turning twinview back on moves the ones which were on the external display back to it, so I can undock and redock from my CRT albeit with a whole lot of mouse clicking.

Now on Intrepid (not sure if this could have been done on Hardy, but anyway) I found a command line way to toggle twinview on and off. I had used nvidia-settings to write to my xorg.conf, which had produced the following:

Section “Screen”
Identifier    “Screen0″
Device        “Videocard0″
Monitor        “Monitor0″
Defaultdepth    24
Option        “TwinView”    “1”
Option        “TwinViewXineramaInfoOrder”    “CRT-0″
Option        “metamodes”    “CRT: 1280x1024_85 +0+0, DFP: nvidia-auto-select +0+1024″
EndSection

This at least allowed me to boot into twinview if the CRT was connected at the time.

I have added a metamode now, so that the line above reads:

Option        “metamodes”    “CRT: 1280x1024_85 +0+0, DFP: nvidia-auto-select +0+1024; CRT: null, DFP: nvidia-auto-select +0+0″

This lets me run “xrandr -s 0″ to select the twinview (CRT at 1280×1024 85 Hz and DFP below it) and “xrandr -s 1″ to turn off twinview.

I then discovered that my Fn+F7 combination automagically does the latter, so I only need to use xbindkeys to enable turning twinview on, so my .xbindkeysrc contains the following:

“exec xrandr -s 0″
Mod4 + F7

That binds it to the combination of Super_L (my Windows key) and F7, so I can undock with Fn+F7 and redock with Win+F7.

This is so much easier than using the nvidia-settings app! It’s going to save literally hours of my life to spend on other things… hope it helps someone else too.

About these ads

9 Responses to “Nvidia twinview and xrandr”


  1. 1 Rob December 15, 2008 at 8:36 pm

    SJEESH,

    I’ve been horsing around with my xorg config trying to get the dock/undock stuff working. As with all good things your solution was Briliantly simple.

    Next to the key shortcuts I’ve also put a short shell script in /etc/X11/Xsession.d/45xrandr that first uses xrandr to detect my external monitor on startup of X, and then uses your command either way to start or shutdown twinview. The script is included below.

    Thanks again,
    Rob

    EXTERNAL_OUTPUT=”Screen 1″
    INTERNAL_OUTPUT=”Screen 0″

    xrandr |grep $EXTERNAL_OUTPUT | grep ” connected ”
    if [ $? -eq 0 ]; then
    xrandr -s 0
    else
    xrandr -s 1
    fi

  2. 2 Armindo February 26, 2009 at 8:56 pm

    I had the same problem till i found disper (http://willem.engen.nl/projects/disper/) which let me do the same without messing with nvidia-settings nor xorg.conf..
    A must check!

  3. 3 jrstravino March 8, 2009 at 7:25 pm

    gnome-randr-applet

    Simple gnome-panel front end to the xrandr extension
    Gnome-randr-applet is a simple gnome-panel front end to the xrandr

    Ubuntu 8.10 repositories…

  4. 4 Arne December 9, 2009 at 12:15 am

    i found this page and now i use ur “;”-metamod-list-xrandr-trick, 2… works great… thx! -arne

  5. 5 Dieter August 5, 2010 at 10:23 am

    This works perfectly! Thanks a lot man! This is the finishing touch to my Ubuntu desktop environment!
    Can’t thank you enough!

  6. 6 A.J. September 29, 2010 at 11:05 pm

    Armindo, thanks for the pointer to disper – it works like a charm! I wrote this little script that gets called on suspend/resume, and automatically fires up the external display if it’s connected:

    #!/bin/sh
    ndisp=`/usr/bin/disper -l | grep display | wc -l`
    if [ $ndisp -ge 2 ]; then
    /usr/bin/disper -e -t left
    else
    /usr/bin/disper -s
    fi

  7. 7 Matt January 8, 2011 at 5:35 am

    I’ve been looking for something to do this for a while. Disper worked out of the box for me. Thanks.

  8. 8 Rob___ October 10, 2011 at 10:56 pm

    Thanks! I used this with some udev rule to control my Dell Latitude E6400 display when docking and undocking Ubuntu 11. That part is here:
    http://ubuntuforums.org/showthread.php?p=11328934#post11328934


Comments are currently closed.




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: