Skip to content

Instantly share code, notes, and snippets.

@ciarand
Created January 24, 2014 04:43
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciarand/8592193 to your computer and use it in GitHub Desktop.
Save ciarand/8592193 to your computer and use it in GitHub Desktop.
Making xrandr modifications permanent with lightdm

Overview

xrandr is the easiest way to make a multiple display configuration work in Linux. Lightdm is my current display manager. This file explains how to make lightdm run an arbritrary script (in this case an xrandr script) on startup.

Here's the command we need:

#!/usr/bin/env bash
xrandr --output DVI-0 --mode 1920x1080 --left-of VGA-0

Obviously you can modify that to fit your specific setup. Any valid command works here.

sudo cat > /usr/share/multiple-monitors.sh << EOF
#!/usr/bin/env bash
xrandr --output DVI-0 --mode 1920x1080 --left-of VGA-0
EOF
sudo chmod +x /usr/share/multiple-monitors.sh

Open up /etc/lightdm/lightdm.conf and change the following line from:

#display-setup-script = 

To:

display-setup-script=/usr/share/multiple-monitors.sh

Restart everything as appropriate. Check in /var/log/lightdm/lightdm.log for errors.

@1nc3p710n
Copy link

1nc3p710n commented Jun 4, 2016

One thing I had issues with was using a bash script to config xrandr for monitors that were connected. It failed no matter where I put it. Others have reported success with your method. However I found the culprit to be xfce reverting any settings I made with lightdm before login. I run xfce with Debian 8 on a vaio laptop, with HDMI as well as VGA monitors connected; usually leaving the laptop lcd closed in a dock while the HDMI and VGA running in extended mode . XFCE in particular has display configs in ~/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml. Those work great on xfce systems that keep the number of monitors static. If not what worked for me was either using the GUI Startup Applications settings menu and placing my script there or alternatively /etc/X11/Xsession.d/99dpconfig (dpconfig was a symlink to my script in /usr/local/bin and) However the secret sauce, for me at least was putting something along the lines of at the beginning.

until [ xrandr ]; do sleep 1 done

@arindas
Copy link

arindas commented Oct 21, 2021

Note: Make the change under the [Seat] section in /etc/lightdm/lightdm.conf

@viniciosaltos93
Copy link

This solution really works, but it is important to clarify that the display-setup-script parameter to modify must be under the section [Seat:*], otherwise it will not work.

@lokka30
Copy link

lokka30 commented May 1, 2022

Thank you! This works great for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment