Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:nvidia_dual_monitor_switching [2011/12/06 17:31]
Joel Dare
linux:nvidia_dual_monitor_switching [2020/06/01 22:53] (current)
Line 1: Line 1:
 +====== nVidia Dual Monitor Switching ======
 +
 +My last few machines have had nVidia video cards in them.  I'm currently running Ubuntu Maverick 10.04 on a MacBook Pro 7,1.  I'm using the nVidia proprietary drivers. Unfortunately,​ those drivers do not currently support automatically switching between single and dual monitor setup (at the time of this writing it's on their to-do list). ​ In order to solve the problem I found a [[http://​ubuntuforums.org/​showthread.php?​p=6480694|post about setting up dual "​metamodes"​]] in the xorg.conf file and then using xrandr to switch back and forth. ​ This works great and I've created launcher icons in my panel for quickly switching back and forth. ​ Below is a copy of that post from swatkins (just in case the original disappears).
 +
 +===== Original Post =====
 +
 +[ SOLVED ] Switch between Dual and Single Monitor
 +I finally found out a nice easy way to do this using xorg.conf and xrandr, which works with nvidia and maybe others.
 +
 +First, if you didn't already, set up the computer to use both monitors using nvidia-settings,​ and save the settings. I'm using twinview.
 +
 +Now make a backup of your /​etc/​X11/​xorg.conf,​
 +
 +  sudo cp /​etc/​X11/​xorg.conf /​etc/​X11/​xorg.conf.before-metamodes.bak
 +
 +If you need to restore the backup at some time, you'll need to log in to the console (ctrl-alt-f1) and do:
 +
 +  sudo cp /​etc/​X11/​xorg.conf.before-metamodes.bak /​etc/​X11/​xorg.conf
 +
 +Now, edit /​etc/​X11/​xorg.conf. If you use gedit:
 +
 +  sudo gedit /​etc/​X11/​xorg.conf
 +
 +find the "​metamodes"​ option, and add a mode for each monitor separately. Mine used to look like this:
 +
 +  Option "​metamodes"​ "CRT: 1440x900_60 +0+0, DFP: 1280x800_60 +80+900"​
 +
 +now it looks like this:
 +
 +  Option "​metamodes"​ "CRT: 1440x900_60 +0+0, DFP: 1280x800_60 +80+900; CRT: NULL, DFP: 1280x800_60 +0+0; CRT: 1440x900_60 +0+0, DFP: NULL"
 +
 +There are three metamodes there, separated by semicolons ;
 +
 +To make the single-monitor metamodes, you should just copy the metamode for both monitors, and replace one monitor'​s settings with "​NULL"​. Also, change the offset to +0+0.
 +
 +Now logout and login again, then type:
 +
 +  xrandr
 +
 +I get:
 +
 +  Screen 0: minimum 1280 x 800, current 1440 x 1700, maximum 1440 x 1700
 +  default connected 1440x1700+0+0 0mm x 0mm
 +    1440x1700 ​     50.0* 
 +    1280x800 ​      ​51.0  ​
 +    1440x900 ​      52.0
 +
 +You can see xrandr now knows about 3 modes, you can select them like:
 +
 +  xrandr -s 0
 +  xrandr -s 1
 +  xrandr -s 2
 +
 +or:
 +
 +  xrandr -s 1440x1700
 +
 +If you have two monitors at the same resolution, you can use the first way "​xrandr -s 1" etc, or something like:
 +
 +  xrandr -s 1280x800 --rate 51
 +
 +Nvidia uses the "​rate"​ option in xrandr to distinguish metamodes that have the same resolution.
 +
 +I tried using nv-control-dpy and some different scripts that I found, it didn't work properly and it's complicated,​ I think this is a much better and easier way.
 +
 +===== Additional Details =====
 +
 +After upgrading to Ubuntu 11.10 this no longer worked. ​ Ultimately I found that my "​metamodes"​ line was the problem. ​ I have two monitors with the following resolutions.
 +
 +| Laptop LCD | 1280x800 |
 +| Dell LCD | 1680x1050 |
 +
 +The Dell is sometimes connected. ​ As a result I needed to setup two metamodes. ​ I did so by putting a semicolon between them.  Here's the "​Screen"​ section of my xorg.conf file.
 +
 +<​code>​
 +Section "​Screen"​
 +    Identifier ​    "​Screen0"​
 +    Device ​        "​Device0"​
 +    Monitor ​       "​Monitor0"​
 +    DefaultDepth ​   24
 +    Option ​        "​TwinView"​ "​1"​
 +    Option ​        "​TwinViewXineramaInfoOrder"​ "​DFP-0"​
 +    Option ​        "​metamodes"​ "​DFP-0:​ 1280x800_60 +0+0, DFP-1: 1680x1050_60 +1280+0; DFP-0: 1280x800_60 +0+0, DFP-1: NULL"
 +    SubSection ​    "​Display"​
 +        Depth       24
 +    EndSubSection
 +EndSection
 +</​code>​
 +
 +Notice that I set the first monitor (DFP-0) to the laptops LCD resolution (1280x800) and I set the second monitor (DFP-1) to NULL. That's because it's not connected in this case.
 +
 +I have a third case, however, that I had a heck of a time getting to work (under any version). ​ And that is an overhead projector that I sometimes connect to in a conference room and that the NVIDIA driver doesn'​t correctly detect the display details for.  For that, I added a middle option to my "​metamodes"​. ​ Here's the line with all three options.
 +
 +  Option ​        "​metamodes"​ "​DFP-0:​ 1280x800_60 +0+0, DFP-1: 1680x1050_60 +1280+0; DFP-0: 1280x800_60 +0+0, DFP-1: 1280x1024_60 +1280+0; DFP-0: 1280x800_60 +0+0, DFP-1: NULL"
 +
  
comments powered by Disqus
linux/nvidia_dual_monitor_switching.txt · Last modified: 2020/06/01 22:53 (external edit)