Goal

The goal of this effort was to use an external monitor or projector on a Linux based laptop (running Ubuntu Linux) equipped with a Nvidia video card:

  • should not require laptop restart
  • should not require X restart
  • should be simple enough

Hardware

  • Dell Inspiron 8600 and Dell Latitude D820 with Nvidia graphics card running at 1680×1050
  • External LCD monitor capable of 1680×1050 (this might not be always the case but surely the solution can be adapted)

First try

My first try was to just plug the monitor and press the Fn + F8 (CRT/LCD) button. Nothing happen even if this is how it should have worked. BUH! I don’t have windows on my laptops but I found a similary laptop with Windows and this worked. Well, probably now it’s a question of drivers. After searching the forums for a while and still nothing I came upon a solution which was supposed to work but it required the external device to be connected on when X started, not good.

The solution

Using the idea which I found on the forums I created a second configuration file /etc/X11/xorg.conf.external with the following device configuration:

Section "Device"<br></br>    Identifier     "NVIDIA Corporation NV34M [GeForce FX Go5200]"<br></br>    Driver         "nvidia"<br></br>    Option         "NvAgp"      "1"<br></br>    Option "TwinView" "Yes"<br></br>    Option "TwinViewOrientation" "Clone"<br></br>    Option "MetaModes" "1680x1050,1680x1050"<br></br>EndSection<br></br>

Then I realized I can start a new X server on :2

Xorg :2 -ac -config /etc/X11/xorg.conf.external

And then in a new terminal start a window manager (I used WindowMaker as you cannot start gnome twice)

export DISPLAY=localhost:2 (here is where the -ac is used)<br></br>wmaker<br></br>

I then switch to the new X with CTRL-ALT-F8 do my work and then finally when not needed anymore I close it without affecting my running X. In fact I found this method even handier as it’s a sandbox for all the applications I want to show and I will not get disturbed during the presentation by an incoming mail or message.

Comments:

Marilen Corciovei -

There is a big difference with your script approach. In your approach this will kill your current X session as you are forcing Xorg to reload a new configuration each time.
In my case you had 2 Xorg running on :1 and :2. You could keep all your windows open on :1, use :2 just for the external monitor (presentation, etc.) and still be able to switch between then.


Karol Krizka -

Hey,
I had the same problem with my laptop and a new monitor. However I tried using the nvidia-settings tool that came with the binary nvidia drivers, and it worked without having to restart anything! I documented my experience with it here:
http://roadkillbunny.blogspot.com/2007/07/external-monitor-on-ubuntu.html


David -

I would add the idea posted here:
http://ubuntuforums.org/showthread.php?t=361124&highlight=intel+dual+monitor

I decided to modify the script given in that thread to take this idea into account. Here’s what I did:

  1. Set up the switching script:
    ::Terminal::

sudo gedit /usr/bin/switchmon

::gedit::

#!/bin/sh

cmd=${0##*/} # Command’s basename
msg="\n\tUsage: $cmd [1|2]\n\t\t1 = Single Monitor\n\t\t2 = VGA Exterrnal Monitor"

if [ $# -lt 1 ]; then
echo $msg
exit 0
fi
if [ $1 = “2” ]; then
echo -e “\nChanging to VGA External Monitor”
# The following two lines are important only if you use Beryl.
# Uncomment the appropriate line for your DE. Comment both out if you don’t use Beryl.
#mv ~/.config/autostart/beryl-manager.desktop ~/.config/beryl-manager.off # <-GNOME
#mv ~/.kde/Autostart/beryl-manager.desktop ~/.kde/beryl-manager.off # <-KDE
sudo cp /etc/X11/xorg.conf.external /etc/X11/xorg.conf
sudo pkill Xorg
echo
exit 2
fi
if [ $1 = “1” ]; then
echo -e “\nChanging to internal LCD”
# The following two lines are important only if you use Beryl.
# Uncomment the appropriate line for your DE. Comment both out if you don’t use Beryl.
#mv ~/.config/autostart/beryl-manager.desktop ~/.config/beryl-manager.off # <-GNOME
#mv ~/.kde/Autostart/beryl-manager.desktop ~/.kde/beryl-manager.off # <-KDE
sudo cp /etc/X11/xorg.conf.single /etc/X11/xorg.conf
sudo pkill Xorg
echo
exit 2
fi

echo “Invalid Number” $msg
exit 0

  1. Set up the config files.
    First, follow the directions above to create xorg.conf.external. Then

::Terminal::
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.single

  1. Make the script executable.
    This involves a simple privilege change:

::Terminal::
sudo chmod +x /usr/bin/switchmon

Then you can switch between the two by calling from terminal either ‘switchmon 1’ or ‘switchmon 2’.


Ricardo -

Hey there, Thanks for the info. It did work for me although I do not use nvidia drivers, (lspci throws: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller). Also I want to say that I have a guest account enabled, and thus I can initialize the second Xorg session using a shell in my guest account, then I use “su” to switch to my real account in a shell, then I do the export DISPLAY and finally start my gnome-session (a little too complicated, but this way I have two working gnome sessions (of course with different users).