joe.terrarum.net

Working With an External Monitor in Ubuntu

Introduction

My laptop uses the Intel 915 graphics chip. I used the i810 X driver previously, but Ubuntu 7.10 now uses the intel driver by default. Using the intel driver, along with the xrandr command, it's really simple to configure an external monitor.

xrandr

By running xrandr by itself, it'll print out a list of available outputs and their resolutions:

$ xrandr

Screen 0: minimum 320 x 200, current 1280 x 768, maximum 1280 x 1280
VGA connected 1024x768+0+0 (normal left inverted right) 338mm x 270mm
1024x768       70.1*    60.0  
832x624        74.6  
800x600        72.2     75.0     60.3     56.2  
640x480        75.0     72.8     66.7     60.0  
720x400        70.1  
LVDS connected 1280x768+0+0 (normal left inverted right) 0mm x 0mm
1280x768       59.9*+   60.0  
1152x768       54.8  
1024x768       85.0     75.0     70.1     60.0  
832x624        74.6  
800x600        85.1     72.2     75.0     60.3     56.2  
640x480        85.0     72.8     75.0     59.9  
720x400        85.0  
640x400        85.1  
640x350        85.1  

Without an external display plugged in to the laptop, only LVDS will display:

$ xrandr

Screen 0: minimum 320 x 200, current 1280 x 768, maximum 1280 x 1280
VGA disconnected (normal left inverted right)
LVDS connected 1280x768+0+0 (normal left inverted right) 0mm x 0mm
1280x768       59.9*+   60.0  
1152x768       54.8  
1024x768       85.0     75.0     70.1     60.0  
832x624        74.6  
800x600        85.1     72.2     75.0     60.3     56.2  
640x480        85.0     72.8     75.0     59.9  
720x400        85.0  
640x400        85.1  
640x350        85.1  

To enable the external display:

$ xrandr --output VGA --mode 1024x768

To disable the laptop display and only run the external (good for "clamshell" mode):

$ xrandr --output LVDS --off

To shut off the external and start the laptop display:

$ xrandr --output VGA --off
$ xrandr --output LVDS --mode 1280x768

keylaunch

Keylaunch is a simple program that lets you specify key combinations to run commands. You store your configuration in ~/.keylaunchrc like so:

# Format:
# key=...KeyName:Command
#
# ... No modifier
# *.. Shift
# .*. Ctrl
# ..* Alt

I used keylaunch in combination with xrandr for quick access to enabling my external monitor. Here's what my .keylaunchrc looks like:

key=***q:xrandr --output VGA --mode 1024x768; xrandr --output LVDS --off
key=***w:xrandr --output VGA --off; xrandr --output LVDS --mode 1280x768
key=***e:xrandr --output VGA --mode 1024x768; xrandr --output LVDS --mode 1280x768

So when I press shift+ctrl+alt+q, the external display will start and the laptop display will shut off.

Quirks

Obviously the ideal method would be to simply press fn-f8 on my laptop and have it switch video modes. Or at least have the Ubuntu monitor config utility help in configuring an external display. But, for some reason or another, neither worked. However, using the 'ol TMTOWTDI adage, this way works fine.

Also, I have the weird problem that when I turn on the laptop with the VGA cable connected, X will start in mirror-mode with both displays at 1024x768 which messes up my laptop display. Therefore, I have to make sure the cable is unplugged when X is starting.