Skip to content

Configuring the MDM login screen with xrandr for mirrored multiple monitors

by on September 7, 2016

Setting up my new laptop with Linux Mint 18 Cinnamon I faced the challenge that on a multi-monitor set up the MDM login screen did not show up well: While it looks great on the laptop monitor the external monitor has the wrong resolution and shows only a part of the login box.

Searching for a solution I stumbled across a post at Segfault (News from the Linux Mint development team):

This post was really helpful to eventually evolve to my solution. I needed a somewhat different approach than in the fixed call to xrandr because I sometimes switch working places. So it needs to be more generic. And the result is this xrandr setup placed directly in front of the exit 0 call in /etc/mdm/Init/Default:

PRIMARY=`xrandr -q|awk '/connected primary/ { print $1 }'`
if [ "x$PRIMARY" = "x" ] ; then
  # take the first one
  PRIMARY=`xrandr -q|awk '/ connected/ { print $1 }'|head -n 1`
fi

if [ "x$PRIMARY" != "x" ] ; then
  SECONDARY=`xrandr -q|awk '/ connected/ && $1 != $PRIMARY { printf "--same-as %s ", $1 }'`
  if [ "x$SECONDARY" != "x" ] ; then
    xrandr --output $PRIMARY --mode 1920x1080 $SECONDARY
  fi
fi

What the script does:

  1. see if xrandr already knows some primary screen to take this as reference
  2. if there is no primary screen take the first connected screen as primary screen
  3. if a primary screen could be determined choose all secondary screens which are all connected screens, which are not equal to the primary screen
  4. add --same-as for all secondary screen
  5. only if primary and secondary screen are present: use xrandr to set up all screens as mirrored screens; use resolution 1920×1080 which fits best for all working spaces

From → Linux, Tips & Tricks

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s