/ Linux

Ubuntu login screen on proper monitor

Whenever you work with an Ubuntu Gnome (using LightDM) laptop, if you plug another monitor and close the lid, the login screen may not appear on the monitor at boot. But still on the closed lid screen. This is how to fix this.

First, get the informations about the current monitor setup

xrandr -q | grep ' connected'
eDP-1-1 connected (normal left inverted right x axis y axis)
DP-1-1-3 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm

According to this, write a /usr/share/lightdm_screen.sh script that'll let lightdm enforce this screen & resolution as primary screen for login.

if [ $(xrandr -q | grep -q $MONITOR) ]
  xrandr --output $MONITOR --primary --mode 1920x1080

Then sudo chmod +x /usr/share/lightdm_screen.sh.

Last step, tell lightdm to call this script

echo 'display-setup-script=/usr/share/lightdm_screen.sh' >> /etc/init/lightdm.conf