On the fly external monitor support (mirroring / spanning) on Ubuntu 7.10

My IBM X31 laptop has the capability to drive an external VGA monitor in addition to it's built in XGA (1024×768) Laptop Video Display Screen (LVDS). The new xrandr extension allows non-privlidged users to change monitor layouts on-the-fly. And now, thanks to my friend Tracy, I know the "extra magic" to make it all work.

The trick is to set up a "Virtual" desktop that is large enough for all of the displays you ever want to drive. In my case that's a 1024×768 laptop display plus a 1024×768 monitor (or projector) on the external VGA port. Assuming I want them side-by-side (instead of above/below) that leads to a 2048×768 "Virtual" display port. 

To do this in Ubuntu, you must edit the /etc/X11/xorg.conf file (you will need root privileges for this, so use the sudo command with your favorite editor — "sudo vi /etc/X11/xorg.conf" in my case.) Then, add a "Virtual 2048 768" line into your Display SubSection (mine looks like this):

        SubSection "Display"
                Modes           "1024×768"
                Virtual            2048 768

After you do this, you'll have to re-start your X-server (ctrl-alt-backspace, or just reboot) for it to take effect.

Note: If you want to drive the external monitor at a larger resolution than your laptop display panel (say, 1280×1024) you'll have to increase the size of your virtual desktop to fit the largest screen plus the smaller screen, so in this example you'd need a "Virtual 2304 1024" entry (1024+1280 = 2304 and the height is the larger of 768 and 1024).

Once you have the virtual desktop size set correctly, you can then use the xrandr command to turn on the external VGA port. You can either mirror the laptop display on the external monitor, or set up the external monitor to the left or right of the laptop display panel (spanning mode) for double the desktop space.

(I found that to switch from mirroring to spanning I had to first turn OFF the external VGA port, but this may be a limitation of my Mobility6 chip from ATI.)

Here are the commands I use (in batch files):

To turn off the external VGA port (saves a small amount of power when on battery power, and keeps people from seeing your desktop on a projector/monitor):

 xrandr –output LVDS –auto –output VGA-0 –off

To turn on the external VGA (mirroring the LVDS):

 xrandr –output LVDS –mode 1024×768 –output VGA-0 –mode 1024×768 –same-as LVDS

(Modify the resolution if your LVDS supports a different native resolution. You can find the supported resolutions using xrandr with no parameters, or just use –auto for the resolution to select the default.)

To turn on the external VGA in spanning mode (for twice the desktop space):

xrandr –output LVDS –auto –output VGA-0 –off
xrandr –output LVDS –auto –output VGA-0 –right-of LVDS –mode 1024×768

NOTE: It is possible for me to drive external monitors at a resolution greater than XGA (for example, I can have a 1024×768 laptop display panel, and a 1280×1024 monitor to the right of my LVDS. I don't do this for two reasons. First, having monitors of different heights messes up the behavior of my auto-hide window panel (at the bottom of my 1024×768 screen) so that it hides and I can't make it pop up. Second, I use my external VGA port mostly to connect to projectors, and believe me, nothing is safer than a plain vanilla XGA (1024×768) signal when you are trying to get a random Projecto-Matic (TM) 1000  unit to work.

Leave a Reply

Your email address will not be published. Required fields are marked *