Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 am on the latest Ubuntu 14.04 with GNOME-3 (not Ubuntu Unity). In my office, I am using Lenovo T410 laptop with an external monitor connected to it via docking station.

What I want is to use ONLY the external monitor whenever the laptop is attached to the docking station.

I can easily achieve this manually with xrandr or with the GUI tool (Displays). They both detect the monitor and work fine. But I want to do it automatically.

I managed to do it on lightdm level. I put this into /etc/lightdm/lightdm.conf:


And here is (here: LVDS-1 is the laptop screen, DP-3 is the monitor):


XCOM0=`xrandr -q | grep 'DP-3 connected'`

if [ -n "$XCOM0" ] || [ ! "$XCOM0" = "" ]
   # external monitor is connected
   xrandr --output LVDS-1 --off --output DP-3 --primary --auto
   # external monitor is disconnected
   xrandr --output LVDS-1 --primary --auto

exit 0;

This works well on lightdm level, the laptop screen is disabled whenever I have my monitor attached.

But when I enter my username/password, the laptop screen is suddenly enabled, extending the monitor. I can't figure out what enables it. Looks like some default setting in GNOME.

How can I prevent GNOME from doing this?

share|improve this question
I didn't try the solution with xorg.conf, because Ubuntu doesn't use it at all by default, so I would prefer to avoid it. But the solution with session-setup-script didn't work for me. I wonder who is turning the dual-screen mode... – Dmitry Perets May 10 '14 at 20:33

Your Answer


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

Browse other questions tagged or ask your own question.