Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 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 ]]
    notify-send "Extending desktop to VGA screen"
    xrandr --output DP-3 --auto --output VGA-0 --auto --right-of DP-3 --primary
    xrandr | grep DP-2 | grep connected >/dev/null
    if [[ "$?" -gt 0 ]]
    notify-send "Extending desktop to DisplayPort screen"
    xrandr --output DP-3 --auto --output DP-2 --auto --right-of DP-3 --primary
    notify-send "No known screens found"


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .