Screen switching on the EeePC

I spend a lot of time working on my EeePC 901 using it’s external monitor support, it’s great, I have this little netbook, but when I plug it in to an external monitor, keyboard and mouse it pretty much turns into a desktop PC. The only drawback I’ve found so far is that there was no way to switch between the monitors in Ubuntu without going through the Screen Resolution configuration dialog. That was until I decided it had annoyed me for long enough and got Googling.

I found this page, which documents the Xrandr, which can be used to configure monitors and screen resolutions from the command line. Some of the code snippets on the page got me into writing a script, which could toggle between the displays and be assigned to a hot key. I also added a mode to switch back to the laptop screen when there is not external screen (just in case my external monitor dies as happened in the power cut the other day!).

# names of outputs
# external and internal resolutions
# if the external output is disconnected, then switch back to internal output
xrandr | grep $EXTERNAL_OUTPUT | grep 'disconnected'
if [ $? -eq 0 ]; then
# just check to make sure we aren't on internal output already
if [ $? -eq 1 ]; then
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
exit 0
# check to see whether the external output is active
if [ $? -eq 0 ]; then
# yep, we're currently using the external output, so switch back to the internal output
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
# otherwise we want to change to the external output
xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT --mode $EXTERNAL_RESOLUTION
exit 0

I assigned this to the Fn-F5 key combination using eee-control, which I already have running on my eeepc. The result is really nice switching between internal and external outputs, which solved my problem perfectly.

Leave a Reply

Your email address will not be published.