When my laptop is on docking station, the boot messages are printed on the laptop screen and not on the external monitor. The earliest time I managed to switch to my external monitor was after login.

I also played with the BIOS settings but that doesn't seem to work as I want, so I am looking for a way to switch to the external monitor (if available) automatically during boot as early as possible.

I am using ubuntu 16.04.1 with systemd, lightdm (and xmonad). The laptop has an onboard intel card and a discrete nvidia card. Only the nvidia card can be used to use the external monitor. I am using the official nvidia drivers for this.

Following the suggestions on how do I prevent Xorg using my Linux laptop's display panel? I put the following in my (otherwise empty) /etc/lightdm/lightdm.conf:

display-setup-script=xrandr --output DP-5.8 --mode "2560x1600" --primary

(Executing that command from commandline does activate the external screen.) However it does nothing. Moving the command into a script made no difference, and putting echo "test" > mylogfile into the script revealed that it's not run on boot.

Edit I just checked if mir is running or not by executing ps -e | grep unity-system-co which resulted in nothing (https://askubuntu.com/a/523012/12015)

  • Is the point when it starts Xorg (lightdm) early enough? unix.stackexchange.com/questions/13619/…
    – JigglyNaga
    Aug 25, 2016 at 13:13
  • @JigglyNaga: I just added for testing the following lines (to my otherwise empty /etc/lightdm/lightdm.conf: [Lightdm] display-setup-script=xrandr --output DP-5.8 --mode "2560x1600" --primary however it does nothing. (Executing the command from commandline does activate the external screen). (After [Lightdm] there is a line break)
    – student
    Aug 25, 2016 at 21:28
  • @JigglyNaga: I also wrapped it into a script and also tried quotes. It doesn't work. About the xorg method I don't really understand what I do. The first problem is that my xorg file seems be automatically recreated after each boot (I just renamed it to xorg.conf.bak and after a reboot there was a xorg.conf file there with the same content as before). Since I am using ubuntu 16.01 I am also not sure, how much native xorg this uses or if its more an xorg emulation provided by mir.
    – student
    Aug 30, 2016 at 10:18
  • Could you expand on "doesn't work"? eg. have the script redirect its output to a log file, so you can see if it runs at all, or generates any errors. If you're using Mir, that's relevant information to include in the question.
    – JigglyNaga
    Aug 30, 2016 at 10:34
  • xorg.conf could also be overwritten by gpu-manager. Ubuntu bug 1310489 says "Fix Released" but the comments suggest users are still affected, so the workarounds in there may help.
    – JigglyNaga
    Aug 30, 2016 at 10:35

1 Answer 1


The display-setup-script line is in the wrong place in your config file. Move it to Seat:* (previously SeatDefaults):


The package includes an example file /usr/share/doc/lightdm/lightdm.conf.gz that shows the correct layout.

Contents of display-setup.sh:


#xrandr's name for the external monitor connection

#bail out if monitor not found
xrandr --query | grep -q "^$MONITOR connected" || exit 0

#the original command that does the switching
xrandr --output "$MONITOR" --mode "2560x1600" --primary

#optional: switch to vt1 and back, to fix with "blank screen" problem
chvt 1
chvt 7
  • With SeatDefaults it's better (I initially used LightDm instead since I have read on askubuntu SeatDefault is depreciated). With SeatDefaults it boots just into a black screen. I have waited several minutes but nothing happens. After going to terminal via Ctrl+Alt+F1 and then back to Ctrl+Alt+F7, it presents me the login screen on the correct external monitor.
    – student
    Aug 30, 2016 at 11:28
  • [LightDM] is in my example file. However with that it doesn't work.
    – student
    Aug 30, 2016 at 11:47
  • With [Seat:*] I get the same problem as described above, i.e. it works after switching to an tty and back. Any idea?
    – student
    Aug 30, 2016 at 19:56
  • I even tried sleep 30 without success. Would it be possible to make the switching to tty and back automatically from the script?
    – student
    Aug 31, 2016 at 9:28
  • Using chvt 1 and chvt 7 after calling xrandr works, thanks. How can I catch the case that the monitor is not connected?
    – student
    Aug 31, 2016 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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