Using xrandr to set display options

I was giving a presentation on my Acer Aspire One netbook recently, and it occured to me that there must be a better way to enable the external display than to restart X. With my old laptop I had the nVidia control panel to control external devices, but this netbook has an integrated Intel GMA display adaptor. It turns out that xrandr (and the GUI front ends) fit the bill nicely.

Basic stuff:
xrandr -q
This displays the information of the currently connected displays.

xrandr --output LVDS --off --output VGA --mode 1024x768
This turns off the internal display and enables the VGA connected device at a resolution of 1024x768. The option you pass to mode should be listed when you run -q.

If you screw things up and there are no displays working, you can ssh in (or switch to a console via ATL-F1, though this may not work). The only catch is that you have to specify the specific X session with -d

xrandr -d :0 --output LVDS --mode 1024x600

This will send the output of X session :0 (the default session, though some people run more than one, if this does not make sense you are probably not one of those people) to the LVDS panel (built in) on my netbook with a resolution of 1024x600

For the CLI impaired, there are a number of GUI front ends to xrandr, such as grandr, the gnome control panel as well as the KDE control center.

More information can be found on the xrandr wiki page.