[TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
mattlach
Level 4
Level 4
Posts: 323
Joined: Mon May 30, 2011 8:34 pm

[TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by mattlach »

Hey everyone,

I recently figured this one out, and figured I'd document it here for posterity.

If you are anything like me, you have multiple screens rotated in different directions which works fine once logged in, but your log-in screen is all messed up.

As an example, here is how I have my screens set up in Cinnamon:
01.png
A 20" 1600x1200 screen in portrait rotated counter clockwise on the left
A 43" 3840x2160 screen in lanscape in the center
Another 20" 1600x1200 screen in portrait rotated clockwise on the right.

Lets just say that on the system login screen (LightDM) the screens are not configured like this, and if you knock your mouse pointer off the center one, it can be surprisingly difficult to get it back, tilting your head sideways and trying to navigate the pointer to the right place.

It also looks cleaner if your login matches the layout you want, so here is how to achieve that.

1.) Configure your screens how you want them in the Display properties settings.

2.) Install and use arandr to create an xrandr string from your preferred layout.

Open a terminal and do the following:

Code: Select all

sudo apt update
sudo apt install arandr
Run arandr from the GUI menu:
02.png
You should see your screen layout as you have it configured.

If you are happy with it as is, then save it to an xrandr string:

Layout Menu -> Save As

Save it somewhere you know where it is, and name it something nice. I chose to put it on my Desktop and name it "lightdm_xrandr.sh"


3.) Prepare the file containing your xrandr string for use:


The file contained my somewhat semi-complicated xrandr string:

Code: Select all

#!/bin/sh
xrandr --output DisplayPort-0 --primary --mode 3840x2160 --pos 1200x0 --rotate normal --output DisplayPort-1 --mode 1600x1200 --pos 0x560 --rotate left --output DisplayPort-2 --off --output HDMI-A-0 --mode 1600x1200 --pos 5040x560 --rotate right
Unless you have the exact screen layout I do, yours will look different.

For good measure I decided to edit it and add an "exit 0" to the end. This is probably not necessary, but it is proper.

Code: Select all

sudo nano ~/Desktop/lightdm_xrandr.sh

Code: Select all

#!/bin/sh
xrandr --output DisplayPort-0 --primary --mode 3840x2160 --pos 1200x0 --rotate normal --output DisplayPort-1 --mode 1600x1200 --pos 0x560 --rotate left --output DisplayPort-2 --off --output HDMI-A-0 --mode 1600x1200 --pos 5040x560 --rotate right
exit 0
after saving, we should check to make sure it is executable. arandr seems to do this by default, but it doesn't hurt to check:

Code: Select all

# ls -l ~/Desktop/lightdm_xrandr.sh
-rwx------ 1 matt matt 263 Oct 22 23:38 lightdm_xrandr.sh
-rwx------ -> Read Write eXecute. Permissions are correct (in Mints default bash config the file should also be listed as green if it is executable)

If it is not executable you can make it so with the following command:

Code: Select all

chmod 700 ~/Desktop/lightdm_xrandr.sh
Then move this script to /etc/lightdm

Code: Select all

sudo mv ~/Desktop/lightdm_xrandr.sh /etc/lightdm/
So now we have a "script" that sets the proper screen orientation. Now we have to tell lightdm to execute it on startup.

4.) Tell lightdm to execute your xrandr string on boot:

First we have to find the config file. Since the file may differ by version or specific configuration, rather than tell you which file I edited, I will show you how to find yours, just in case yours is different.

Run lightdm --show-config to display the current configuration.

Code: Select all

# lightdm --show-config

   [Seat:*]
A  allow-guest=false
C  greeter-wrapper=/usr/lib/lightdm/lightdm-greeter-session
D  guest-wrapper=/usr/lib/lightdm/lightdm-guest-session
E  xserver-command=X -core
F  greeter-session=slick-greeter
G  user-session=cinnamon

   [LightDM]
B  backup-logs=false

Sources:
A  /usr/share/lightdm/lightdm.conf.d/50-disable-guest.conf
B  /usr/share/lightdm/lightdm.conf.d/50-disable-log-backup.conf
C  /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf
D  /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf
E  /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf
F  /usr/share/lightdm/lightdm.conf.d/90-slick-greeter.conf
G  /etc/lightdm/lightdm.conf.d/70-linuxmint.conf
Look for a config file that says something about "slick greeter". In my case this was:
/usr/share/lightdm/lightdm.conf.d/90-slick-greeter.conf

Edit this file:

Code: Select all

# sudo nano /usr/share/lightdm/lightdm.conf.d/90-slick-greeter.conf
By default it should look like this:

Code: Select all

[Seat:*]
greeter-session=slick-greeter
Add this line between [Seat:*] and greeter-sessiion as follows:

greeter-setup-script=/etc/lightdm/lightdm_xrandr.sh

Code: Select all

[Seat:*]
greeter-setup-script=/etc/lightdm/lightdm_xrandr.sh
greeter-session=slick-greeter
Reboot. Your login screen should now be oriented the same as your desktop once logged in.

I hope this helps someone else.
Corsair 1000D, Threadripper 3960x, Asus ROG Zenith II, 64GB, Samsung 990 Pro, Geforce RTX 4090, 42" LG C3, 2x Dell U2412M, Schiit Bifrost Multibit DAC
Server: AMD EPYC 7543(32C/64T), SuperMicro H12SSL-NT, 512GB RAM, 192TB ZFS
User avatar
SMG
Level 25
Level 25
Posts: 31767
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by SMG »

mattlach wrote: Sun Nov 07, 2021 3:56 pmI hope this helps someone else.
It did. I recommended your tutorial to someone with a slightly different issue and it worked for them .
Image
A woman typing on a laptop with LM20.3 Cinnamon.
mattlach
Level 4
Level 4
Posts: 323
Joined: Mon May 30, 2011 8:34 pm

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by mattlach »

SMG wrote: Mon Nov 29, 2021 9:14 pm
mattlach wrote: Sun Nov 07, 2021 3:56 pmI hope this helps someone else.
It did. I recommended your tutorial to someone with a slightly different issue and it worked for them .
Nice! That makes spending the time on the write-up worth it!
Corsair 1000D, Threadripper 3960x, Asus ROG Zenith II, 64GB, Samsung 990 Pro, Geforce RTX 4090, 42" LG C3, 2x Dell U2412M, Schiit Bifrost Multibit DAC
Server: AMD EPYC 7543(32C/64T), SuperMicro H12SSL-NT, 512GB RAM, 192TB ZFS
Mosfetwall
Level 1
Level 1
Posts: 4
Joined: Fri Sep 27, 2019 5:27 pm

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by Mosfetwall »

@mattlach Thanks mate !

The login orientation of my second monitor was driving me insane :).
mattlach
Level 4
Level 4
Posts: 323
Joined: Mon May 30, 2011 8:34 pm

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by mattlach »

To update this a little.

I just upgraded from 20.2 to 20.3. IN doing so, the installer seems to have overwritten the slick greeter config file:

/usr/share/lightdm/lightdm.conf.d/90-slick-greeter.conf

Everything else seems to have been untouched, so after upgrading, if you just repeat the last step (adding the line to 90-slick-greeter.conf) everything should work again.
Corsair 1000D, Threadripper 3960x, Asus ROG Zenith II, 64GB, Samsung 990 Pro, Geforce RTX 4090, 42" LG C3, 2x Dell U2412M, Schiit Bifrost Multibit DAC
Server: AMD EPYC 7543(32C/64T), SuperMicro H12SSL-NT, 512GB RAM, 192TB ZFS
User avatar
AndyMH
Level 21
Level 21
Posts: 13714
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by AndyMH »

I do similar things - set display resolution on boot with xrandr. But:

In /etc/lightdm/lightdm.conf.d, I have a file 70-linuxmint.conf. Create a new file 71-linuxmint.conf, i.e. a higher number.

Content of 71-linuxmint.conf is:

Code: Select all

[SeatDefaults]
user-session=cinnamon
display-setup-script=/usr/bin/LGmonitor.bsh
It is pointing at a setup script to set the resolution on my monitor.

It does not get overwritten on an update.
the installer seems to have overwritten the slick greeter config file:
If you had created a /usr/share/lightdm/lightdm.conf.d/91-slick-greeter.conf it would not have been overwritten.

Code: Select all

xrandr --output DisplayPort-0 --primary --mode 3840x2160 --pos 1200x0 --rotate normal --output DisplayPort-1 --mode 1600x1200 --pos 0x560 --rotate left --output DisplayPort-2 --off --output HDMI-A-0 --mode 1600x1200 --pos 5040x560 --rotate right
It would be a wise move to wrap this statement in some if statements checking that the monitors are configured as the line expects. You could end up with a system with no graphical display if one or more of the ports are not connected. I know, I've made this mistake.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
mattlach
Level 4
Level 4
Posts: 323
Joined: Mon May 30, 2011 8:34 pm

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by mattlach »

AndyMH wrote: Sat Jan 08, 2022 7:43 pm I do similar things - set display resolution on boot with xrandr. But:

In /etc/lightdm/lightdm.conf.d, I have a file 70-linuxmint.conf. Create a new file 71-linuxmint.conf, i.e. a higher number.

Content of 71-linuxmint.conf is:

Code: Select all

[SeatDefaults]
user-session=cinnamon
display-setup-script=/usr/bin/LGmonitor.bsh
It is pointing at a setup script to set the resolution on my monitor.

It does not get overwritten on an update.
the installer seems to have overwritten the slick greeter config file:
If you had created a /usr/share/lightdm/lightdm.conf.d/91-slick-greeter.conf it would not have been overwritten.

Code: Select all

xrandr --output DisplayPort-0 --primary --mode 3840x2160 --pos 1200x0 --rotate normal --output DisplayPort-1 --mode 1600x1200 --pos 0x560 --rotate left --output DisplayPort-2 --off --output HDMI-A-0 --mode 1600x1200 --pos 5040x560 --rotate right
It would be a wise move to wrap this statement in some if statements checking that the monitors are configured as the line expects. You could end up with a system with no graphical display if one or more of the ports are not connected. I know, I've made this mistake.
Good to know, thank you. I'll play around a little it with that and update the guide up top.
Corsair 1000D, Threadripper 3960x, Asus ROG Zenith II, 64GB, Samsung 990 Pro, Geforce RTX 4090, 42" LG C3, 2x Dell U2412M, Schiit Bifrost Multibit DAC
Server: AMD EPYC 7543(32C/64T), SuperMicro H12SSL-NT, 512GB RAM, 192TB ZFS
mattlach
Level 4
Level 4
Posts: 323
Joined: Mon May 30, 2011 8:34 pm

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by mattlach »

Mosfetwall wrote: Sun Dec 26, 2021 8:03 am @mattlach Thanks mate !

The login orientation of my second monitor was driving me insane :).
I'm glad it was helpful!
Corsair 1000D, Threadripper 3960x, Asus ROG Zenith II, 64GB, Samsung 990 Pro, Geforce RTX 4090, 42" LG C3, 2x Dell U2412M, Schiit Bifrost Multibit DAC
Server: AMD EPYC 7543(32C/64T), SuperMicro H12SSL-NT, 512GB RAM, 192TB ZFS
User avatar
EvilSupahFly
Level 3
Level 3
Posts: 126
Joined: Sat May 24, 2014 11:10 am
Location: Mordor

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by EvilSupahFly »

I upgraded from LM20 to LM21 and lost my login display settings. I came upon your guide after questing on Google but it didn't work. My login screens are still the wrong resolution, but everything is fine once I log in.
My Frankensteined Black Beast:
Intel Core i7-4770S CPU @ 3.10GHz × 8 x64
NVIDIA GeForce GTX 1660, 2 monitors @ 1920x1080
E220x Gigabit Ethernet 1000 Mbps
Storage: 13.01 TB
Intel 8 C220 HD Audio, full 5.1 Surround
User avatar
EvilSupahFly
Level 3
Level 3
Posts: 126
Joined: Sat May 24, 2014 11:10 am
Location: Mordor

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by EvilSupahFly »

I found a better solution:

Instead, login and set your preferred screen settings (click "Apply" if anything changed), then open a terminal and run this command:

Code: Select all

sudo cp ~/.config/monitors.xml /var/lib/lightdm/.config/monitors.xml
Login resolution should now reflect the settings of the user signed in. Some people suggest making a hard link:

Code: Select all

sudo ln ~/.config/monitors.xml /var/lib/lightdm/.config/monitors.xml
But that only works if your home folder is on the same physical drive. Since my OS is on a different physical drive from my user folder (~), I had to copy the file instead of linking it. Note as well that it must be a hard link - symbolic links will not work.
Last edited by EvilSupahFly on Wed Sep 21, 2022 1:34 pm, edited 2 times in total.
My Frankensteined Black Beast:
Intel Core i7-4770S CPU @ 3.10GHz × 8 x64
NVIDIA GeForce GTX 1660, 2 monitors @ 1920x1080
E220x Gigabit Ethernet 1000 Mbps
Storage: 13.01 TB
Intel 8 C220 HD Audio, full 5.1 Surround
User avatar
SMG
Level 25
Level 25
Posts: 31767
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by SMG »

EvilSupahFly wrote: Wed Sep 21, 2022 11:05 am I found a better solution:
What desktop environment of Linux Mint are you running and when did you last do a fresh install?

LM20 Cinnamon (and newer) versions do not have a monitors.xml file. They have a cinnamon-monitors.xml file.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
User avatar
EvilSupahFly
Level 3
Level 3
Posts: 126
Joined: Sat May 24, 2014 11:10 am
Location: Mordor

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by EvilSupahFly »

SMG wrote: Wed Sep 21, 2022 11:10 am
EvilSupahFly wrote: Wed Sep 21, 2022 11:05 am I found a better solution:
What desktop environment of Linux Mint are you running and when did you last do a fresh install?

LM20 Cinnamon (and newer) versions do not have a monitors.xml file. They have a cinnamon-monitors.xml file.
I'm running LM21 but I've been upgrading-in-place since LM16. Last clean install was LM16. Naming the file cinnamon-monitors.xml would probably work too.
My Frankensteined Black Beast:
Intel Core i7-4770S CPU @ 3.10GHz × 8 x64
NVIDIA GeForce GTX 1660, 2 monitors @ 1920x1080
E220x Gigabit Ethernet 1000 Mbps
Storage: 13.01 TB
Intel 8 C220 HD Audio, full 5.1 Surround
User avatar
SMG
Level 25
Level 25
Posts: 31767
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by SMG »

Moderator note: WolvenSpectre's issue can now be found here Problems making Log in Screen use same Display Properties as When Logged in on LM21 because, as indicated right at the top, "Don't add support questions to tutorials please; start your own topic in the appropriate sub-forum instead."
Image
A woman typing on a laptop with LM20.3 Cinnamon.
User avatar
Berlyn
Level 1
Level 1
Posts: 7
Joined: Fri Apr 28, 2023 4:28 am
Location: Melbourne, Australia

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by Berlyn »

I know this isn't the most valuable reply to the thread, but I made an account on these forums just so I could say that this tutorial was immensely helpful. I used it to get my portrait monitor to appear correctly instead of sideways. Thank you.
User avatar
PaulL
Level 6
Level 6
Posts: 1030
Joined: Mon Apr 24, 2023 10:57 am
Location: Connecticut

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by PaulL »

I just want to say thank you for this tutorial. I only discovered the tutorials section of this forum by accident, and I'm glad I did. You solved the exact problems I've been looking for help for.

I had a moment of panic, because I entered the location of your script file instead of my own, and so on rebooting I got black screens with blinking cursors. But it only took a moment's thought to figure out what the problem was, and now I can log in with my cursor functioning properly and my background properly displayed. Again, thank you so much!
JezekiljMonk
Level 3
Level 3
Posts: 106
Joined: Mon Dec 30, 2019 7:33 am
Contact:

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by JezekiljMonk »

HI mattlach
Thanks for posting this tutorial.
I tested it first of all on my linuxmint machines in VirtualBox. It turns out that it works on Linuxmint 20.x and 21.x for Cinnamon and only on Linuxmint 21.x with MATE, but not with Linuxmint 20.x with MATE. Don't know yet if this could be something related to VirtualBox but still I am only testing with MATE, not exactly working so it didn't even matter.
In order to test faster I wrote a short script that basically does everything you wrote, except for adopting AndyMH proposal and create file 91-slick-greeter.conf instead of 90-slick-greeter.conf.

Code: Select all

#!/usr/bin/bash
a=$(xrandr --verbose | awk -F'[ +x]' '$2=="connected" { if ($3=="primary") {print " --output "$1" --primary --mode "$4"x"$5" --pos "$6"x"$7" --rotate "$10} else {print " --output "$1" --mode "$3"x"$4" --pos "$5"x"$6" --rotate "$9}}; $2=="disconnected"{print " --output "$1" --off"}')
echo "Enter file name to save current configuration!"
echo "Please, no special character at the end of the file name"
name_of_file=''
while [[ -z $name_of_file ]]
do
    read -p "Please, only letters, numbers, dot '.', hyphen '-' and underscore '_': " name_of_file
    if [[ ! -z "$(echo $name_of_file | sed 's/[a-zA-Z0-9._-]//g')""$(echo ${name_of_file: -1} | sed 's/[a-zA-Z0-9]//')" ]]      # When name is correct both these strings will be empty so also the resulting string is empty
    then
        name_of_file=''     # When file name is not OK there will be new input request
    fi
done
name_of_file+=".sh"
echo "#!/bin/sh" > ~/.config/$name_of_file
echo "xrandr "$a >> ~/.config/$name_of_file
sudo mv ~/.config/$name_of_file /etc/lightdm/
sudo chown root:root /etc/lightdm/$name_of_file
sudo chmod 775 /etc/lightdm/$name_of_file
sudo bash -c "sed '1a "greeter-setup-script=/etc/lightdm/"${name_of_file}' /usr/share/lightdm/lightdm.conf.d/90-slick-greeter.conf > /usr/share/lightdm/lightdm.conf.d/91-slick-greeter.conf"
echo "That's it!"
read -p "Press Enter to exit"
vimes666
Level 6
Level 6
Posts: 1227
Joined: Tue Jan 19, 2016 6:08 pm

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by vimes666 »

In case it still does not work:
I got an error in the syslog saying the desired mode was not found when the script was executed. I think that is a bug that occurs sometimes if the mode you are setting is the same as the current mode. In my case I only wanted to change the frequency for that mode.
I was able to fix this by adding a bare xrandr command right before the mode changing xrandr.
If you think the issue is solved, edit your original post and add the word solved to the title.
egraeler
Level 1
Level 1
Posts: 3
Joined: Sun Sep 04, 2022 9:14 pm

Re: [TUTORIAL] Make Log in Screen (LightDM) use same Display Properties as When Logged in

Post by egraeler »

FYI... I just upgraded to LM21.3 and this still works on that version as well. :) Thanks again for the nice write up!
Post Reply

Return to “Tutorials”