Disable laptop monitor if external monitor is plugged

At work now I use an old laptop connected to a monitor. With arandr you have a GUI for spacer.gifspacer.gifsetting the dual monitors. What I wanted was to switch off the built-in display:

 EXTERNAL_OUTPUT="VGA" 
INTERNAL_OUTPUT="LVDS" 
xrandr |grep $EXTERNAL_OUTPUT | grep " connected " 
if [ $? -eq 0 ];
then xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT --auto 
else xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off 
fi
Advertisements