[DM] Multi-monitor configuration

When having multple monitors on system boot, your Display Manager (SDDM, LightDM, GDM etc) will usually not display correctly in respect to your configured Xorg settings, if not configured properly.
To fix this, a popular and fairly proper and easy method is to use an Xsetup script for your Display Manager.

Xsetup script is a script (executable) file that includes some instructions to the Xorg server, just before starting the Display Manager

Here are these settings for SDDM and LightDM, while they can be adapted/adjusted easily for other DMs.


Create Xsetup script

Create a text file as and make it executable.

sudo touch /etc/X11/xorg.conf.d/dm-multimonitor.sh
sudo chmod +x /etc/X11/xorg.conf.d/dm-multimonitor.sh

Paste these contents and save.

The example is for two monitors, checking if one is not connected and applying relevant settings with xrandr command. You should edit these commands, according to your own actual setup.

#!/bin/sh
# get the correct actual monitor names with
# xrandr | awk ' /connected/ { print $1, $2 }'
mon1=VGA-1-1
mon2=HDMI-0
# Uncomment the sleep command, if you face problems, as a possible workaround
# sleep 3
if xrandr | grep "$mon2 disconnected"; then
    xrandr --output "$mon2" --off --output "$mon1" --auto
elif xrandr | grep "$mon1 disconnected"; then
    xrandr --output "$mon1" --off --output "$mon2" --auto
else 
    xrandr --output "$mon1" --auto --output "$mon2" --right-of "$mon1" --auto
fi

Add custom DM setting

Create a file as

  • For SDDM
/etc/sddm.conf.d/Xsetup.conf
  • For LightDM
/etc/lightdm/lightdm.conf.d/Xsetup.conf

with the following contents

  • For SDDM
[X11]
# Path to a script to execute when starting the display server
DisplayCommand=/etc/X11/xorg.conf.d/dm-multimonitor.sh
  • For LightDM
[Seat:*]
display-setup-script=/etc/X11/xorg.conf.d/dm-multimonitor.sh

Now you are ready to restart your Display Manager to see the results.
Log out your session, or you will see it at your next boot.

10 Likes

Forum kindly sponsored by Bytemark