Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 3rd July 2012, 09:23 PM
lendrick Offline
Registered User
 
Join Date: May 2008
Posts: 13
linuxfirefox
Dual monitor display switching on a laptop with the proprietary nvidia drivers

Update: I'm told that the latest betas of the proprietary nvidia drivers support hot plugging monitors, so it's possible that this will be unnecessary in the future.

I just set this up on my own Fedora 17 machine, and I figured I'd pass the information along so that other technically inclined people can get semi-decent monitor switching working on their laptops under Linux. Before I start, I would like to point out something very important: It's 20f***ing12, not 1995. This should not be necessary, and I'm annoyed that I had to do it. I'm doubly annoyed that it appears that there's absolutely no system event that fires off when a monitor is plugged in or unplugged.

Anyway, after mucking around over many days, I arrived at a halfway decent solution that allows my laptop, if not to automatically detect and react when a monitor is plugged in, to at least detect the display configuration with a single keypress.

Before we get started, you'll need:
  • A basic knowledge of BASH scripting
  • An nVidia card with the proprietary drivers (YMMV with other setups; sorry, I can't help you there)
  • Disper -- Download, compile, and install it yourself.

Starting out:

First, plug in all your monitors and run this command:

Code:
disper -l
You should see something like this:

Code:
display DFP-0: Chi Mei Optoelectronics corp.
 resolutions: 320x175, 320x200, 360x200, 320x240, [...]
display CRT-0: Acer H233H
 resolutions: 320x240, 400x300, 512x384, 640x480, [...]
display DFP-1: Acer S232HL
 resolutions: 320x175, 320x200, 360x200, 320x240, [...]
(The [...]s are mine, just removed a bunch of extra resolutions that aren't relevant).

Note all the displays that are connected to your computer. If your laptop is like mine, you might have a DFP-0, DFP-1, and CRT-0. My laptop has a DisplayPort and a VGA port. CRT-0 is the VGA port, and DFP-0 and DFP-1 are the laptop monitor and the DisplayPort, respectively. You can verify which display is which by unplugging them and running 'disper -l' again.

Once you've done this, run:

Code:
nvidia-settings
You do not need to run this as root. For each typical monitor configuration that you want to handle:
  • Go to 'X Server Display Configuration' inside nvidia-settings and set up the desired configuration, then click on 'Apply'
  • From your command line, type 'disper -p > $HOME/disper.WHATEVER' (where WHATEVER is some short description of the display -- I use disper.laptop, disper.dual, and disper.single)

When you're done, you can test each of these sets of display settings from the command line by typing:

Code:
disper -i < disper.WHATEVER
Now it's time to write a BASH script to detect what monitors are plugged in and choose the configuration automatically based on that. Here's mine:

Code:
#!/bin/bash

if disper -l | grep -q 'CRT-0' ; then
  # If the VGA port is connected, I'm assuming that the DisplayPort
  # is connected to, and going with my dual monitor setup.
  echo "Configuring dual external displays"
  disper -i < /home/bart/disper.dual
elif disper -l | grep -q 'DFP-1' ; then
  # If the DisplayPort is connected (but the VGA port is not), then I'm
  # going with the single DisplayPort setup.
  echo "Configuring single external display"
  disper -i < /home/bart/disper.single
else
  # If neither monitors are connected, go with the laptop-only setup.
  echo "Configuring laptop display"
  disper -i < /home/bart/disper.laptop
fi
One thing that my script is missing is a VGA-only setup, but that's reasonably simple to add. Put this script somewhere that you can easily run it from the command line (/usr/local/bin, or $HOME/bin, if that's in your $PATH). Now, when you change monitors, you can run the script from the command line and not have to restart X.

We're almost done. Now we want to auto-detect your monitor setup on boot. At the end of /etc/gdm/Init/Default (before the exit 0), add the full path to your script (and remember that if you put it in $HOME bin, to type out your home directory here, since it's not going to know what your $HOME is before you've logged in).

Finally, set up keyboard shortcuts in your desktop environment that run the script. I'm using KDE, so I configured mine in System Settings -> Shortcuts and Gestures and added preset actions. You may be running GNOME, and I assume there's a way to set up global hotkeys there too, although I don't know it offhand.

I apologize if this is convoluted. I'm providing this for two reasons: One, so technically inclined people can make it work, and two, to point out how incredibly stupid it is that I have to do this at all.

Last edited by lendrick; 4th July 2012 at 07:52 PM.
Reply With Quote
Reply

Tags
display, drivers, dual, laptop, monitor, nvidia, proprietary, switching

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
nVidia Proprietary Drivers cdmac Using Fedora 4 29th March 2011 06:47 PM
Proprietary or open source NVidia drivers? Valent Using Fedora 9 14th October 2010 10:09 PM
Fedora 10 Dual Display settings tool detecting external monitor as laptop LCD gaaschk Hardware & Laptops 2 12th March 2009 03:21 PM
Spanning Dual Display (Laptop and external DVI-D Monitor) vodamaxe Hardware & Laptops 5 26th May 2008 11:36 PM
reverting to Non Proprietary Nvidia drivers. quacked Hardware & Laptops 3 13th December 2007 04:14 AM


Current GMT-time: 16:21 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat