Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a laptop which I want to have connected to an external monitor 99% of the time. The other 1% I would use its screen. I want the laptop to be closed (usually) to save space, and to use external KB/mouse. The external monitor supports a higher resolution than the laptop screen, so I won't use screen duplication, and extended desktop is annoying when one of the monitors can't be viewed, so also out of the question.

Is there a simple way to enable the external only configuration, but that would switch to the internal monitor when the external monitor is disconnected, like regular ubuntu/windows/etc provide?

In addition/alternatively, What software does regular ubuntu or other linux distros use to enable this?

Thanks in advance!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It is probably a Gnome or Unity feature which is absent from LXDE. You could probably write a udev rule to do this on monitor disconnect.

I have written a little script that will detect the monitors and extend accordingly:

#!/usr/bin/env bash

xrandr | grep VGA | grep -w connected >/dev/null
echo $?
if [[ "$?" -lt 1 ]]
then
    notify-send "Extending desktop to VGA screen"
    xrandr --output DP-3 --auto --output VGA-0 --auto --right-of DP-3 --primary
else
    xrandr | grep DP-2 | grep connected >/dev/null
    if [[ "$?" -gt 0 ]]
    then
    notify-send "Extending desktop to DisplayPort screen"
    xrandr --output DP-3 --auto --output DP-2 --auto --right-of DP-3 --primary
    else
    notify-send "No known screens found"
    fi

fi

You need to have xrandr installed but you almost certainly do. You will also need to change the monitor names accordingly (in my case I switch between an external VGA and and external Display Port display). Run xrandr with your external screen connected to getthe right name or update your question with the output of xrandr and I can help you with it.

I have mapped this script to be run with a keyboard shortcut and simply run it whenever I connect or disconnect a screen.

share|improve this answer
    
Thanks! I also found this github repository which I like better since there is no polling. I will accept your answer nevertheless, since it provides a solution! –  Shwouchk Sep 3 '13 at 0:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.