ThreadStates

A Script for Toggling Display Modes using Xrandr

I recently got a netbook, an Acer Aspire One aod150. I immediately installed Arch Linux on it. Most things work out of the box with the exception of several of the Fn key combinations. I've been able to get most of them working, notably sleep and hibernate with pm-utils. The last one that was bugging me was the key combo to toggle the display modes when connected to a projector or external monitor. The behavior I wanted is easily described in the following diagram:

toggle states diagram

In other words, pressing the key combo when the external monitor is disconnected should do nothing. If the external monitor is connected and on then the display should be mirrored. Pressing again should turn the netbook's internal monitor off leaving the external on. Another press should return the display to its initial state.

I implemented this behavior with a shell script using xrandr. I bound the script to the appropriate key combo with xbindkeys. You can get the current version of the script on github. Let me know if you have any questions or problems (pete dot morris at gmail).