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!).

#!/bin/sh
# names of outputs
EXTERNAL_OUTPUT="VGA"
INTERNAL_OUTPUT="LVDS"
# external and internal resolutions
EXTERNAL_RESOLUTION="1024x768"
INTERNAL_RESOLUTION="1024x600"
# 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
xrandr | grep $INTERNAL_OUTPUT | grep $INTERNAL_RESOLUTION
if [ $? -eq 1 ]; then
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
fi
exit 0
fi
# check to see whether the external output is active
xrandr | grep $EXTERNAL_OUTPUT | grep $EXTERNAL_RESOLUTION
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
else
# otherwise we want to change to the external output
xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT --mode $EXTERNAL_RESOLUTION
fi
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. Required fields are marked *