If you, like me, are sick of having to restart the XServer when you undock/dock your laptop in order to get the display to reconfigure (ok, so I've only undocked once since I installed Linux; still, I was bugged), your days of wo are numbered.
X RandR is a command line tool allowing the XServer to dynamically change the configuration. To save you from writing your own shell script utilizing xrandr, two tools have been created:
- Disper: http://willem.engen.nl/projects/disper/
- autorandr: https://github.com/wertarbyte/autorandr
In Ubuntu you should already have xrandr installed. Install Disper using the Debian package above (or build it from source, if you'd like). Update: The version above is 0.2.3, which has worked great for me, even in Ubuntu 11.04. The newer disper, 0.3.0, does not work for me. Disper sounds like it is geared towards NVidia cards. While it (or the plain autorandr alone) may work fine for ATI cards, you may want to take a look at this page (http://www.thinkwiki.org/wiki/Script_for_Dynamic_Display_Management_with_fglrx) if you have an ATI card.
Once xrandr and Disper are both in place, download the autorandr script from the link above, and place it where you'd like to run it from. The most documentation I've found for it is within the comments of the script, so read through those. It is suggested on this issue page (https://github.com/wertarbyte/auto-disper/issues/issue/5) to use the auto-disper symlink if you have an NVidia card. The basic usage is:
auto-disper --save <profile_name>
Then to toggle profiles:
Again, the comments in the script explain this and a bit more, so read through those. Set up your typical docked display configuration and save that as something like 'docked'. Then do what you need to to set up your typical undocked configuration and save that as something like 'undocked'. The names are arbitrary unless you call them with `--load docked`, which I do not.
Finally, I have added a global keyboard shortcut in gnome so that Shift+Ctrl+F7 calls `auto-disper --change`. I have tried to get the FN+F7 switch display button to work for this (per these instructions: http://www.thinkwiki.org/wiki/Sample_Fn-F7_script), but haven't yet succeeded. The ACPI event is triggered and arbitrary scripts I write are called, but for some reason calling auto-disper in that way still doesn't work.
Update: When saving a profile you may get the error: `could not get scaling for screen CRT-0, reverting to "default"`. Something out there lead me to believe that was irrelevant, but in any case I have thus far ignored it with no noticeable issues.