Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

[SeatDefaults]
display-setup-script=/usr/share/lightdmxrandr.sh

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

#!/bin/bash

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

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

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
1  
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 at 20:33

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.