Display Manager multi-monitor configuration

When having multiple 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 arre these settings for SDDM, while they can be adapted/adjusted easily for other DMs.

Create Xsetup script

Create a text file as

/etc/X11/xorg.conf.d/dm-multimonitor.sh

and make it executable.
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
# wait 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 SDDM sddm setting snippet

Create a file as

/etc/sddm.conf.d/Xsetup.conf

with the following contents

[X11]
# Path to a script to execute when starting the display server
DisplayCommand=/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.

14 Likes

2 posts were split to a new topic: Multi-monitor Xsetup script not working after sleep