Skip to content

Instantly share code, notes, and snippets.

@Tedpac
Last active August 20, 2026 23:14
Show Gist options
  • Select an option

  • Save Tedpac/fe4b0d0ee23e7aa53cff7b67bc717bee to your computer and use it in GitHub Desktop.

Select an option

Save Tedpac/fe4b0d0ee23e7aa53cff7b67bc717bee to your computer and use it in GitHub Desktop.
Make the LightDM login screen use only the primary display, at its maximum resolution and refresh rate.

LightDM Greeter Display Setup

The LightDM login screen (greeter) runs before any user session exists, so it ignores your desktop's display configuration: on multi-monitor setups it typically brings up every screen at its EDID-preferred refresh rate (usually ~60 Hz), unrotated, and with a duplicated background.

This Gist installs a small Bash script into LightDM's official greeter-setup-script hook. Right before the greeter appears, it turns off every connected display except the primary one and drives the primary at its maximum detected resolution and refresh rate. If the primary display is not connected, it does nothing and LightDM behaves exactly as stock.

Why this approach

  • Hardware-agnostic: Only the primary output's name is declared; resolution and refresh rate are detected on every boot, so it survives monitor upgrades and works with any number of displays.
  • Official mechanism: It uses the free greeter-setup-script hook, leaving the distribution's own display-setup-script untouched. Two small files under /etc/lightdm/, fully reversible.
  • Robust script: It follows Bash best practices and always exits successfully, since a failing setup script would keep the greeter from starting; at worst you get the stock login screen, never a lockout.

Requirements

LightDM on X11 (tested with slick-greeter on Linux Mint Cinnamon). Only standard tools are used: bash, xrandr, and awk.

Installation

  1. Find your primary output's name and, if it is not DP-0, edit the PRIMARY_OUTPUT variable inside the installer:

    xrandr --query | grep ' connected'
    
  2. Run the installer (it will ask for your sudo password). It creates /etc/lightdm/greeter-display-setup.sh and /etc/lightdm/lightdm.conf.d/95-greeter-display-setup.conf:

    bash install-greeter-display-setup.sh
    
  3. Reboot.

Verification

  • At the login screen, only the primary display should be on, with visibly smooth motion on high-refresh panels.

  • LightDM loaded the configuration and ran the script successfully:

    sudo grep -n 'greeter-display-setup' /var/log/lightdm/lightdm.log
    
  • The X server set the primary display's maximum mode before the session started:

    grep -n 'Setting mode' /var/log/Xorg.0.log
    

Uninstall

sudo rm /etc/lightdm/greeter-display-setup.sh /etc/lightdm/lightdm.conf.d/95-greeter-display-setup.conf
sudo bash -s << 'INSTALLER'
set -e
install -m 755 /dev/stdin /etc/lightdm/greeter-display-setup.sh << 'SCRIPT'
#!/bin/bash
#
# LightDM greeter display setup:
# - Turns off every connected display except the primary one.
# - Applies the maximum resolution and refresh rate to the primary display.
# - If the primary display is not connected, does nothing at all, keeping
# LightDM's default behavior.
#
# Note: no strict mode on purpose. This script must always exit successfully,
# because a failing setup script would prevent the greeter from starting.
readonly PRIMARY_OUTPUT="DP-0"
# Single snapshot of the current display state.
xrandr_query="$(xrandr --query)"
# Prints "WIDTHxHEIGHT RATE" (maximum area, then maximum rate) for the given
# output; prints nothing if it is not connected or has no valid modes.
get_max_mode() {
local output_name="$1"
awk -v target="$output_name" '
$1 == target && $2 == "connected" { in_block = 1; next }
in_block && $0 !~ /^ / { in_block = 0 }
# Only real "WIDTHxHEIGHT" mode lines qualify as candidates.
in_block && $1 !~ /^[0-9]+x[0-9]+$/ { next }
in_block {
resolution = $1
split(resolution, dims, "x")
area = dims[1] * dims[2]
for (i = 2; i <= NF; i++) {
rate = $i
gsub(/[*+]/, "", rate)
if (rate ~ /^[0-9]+\.[0-9]+$/ && (area > best_area || (area == best_area && rate + 0 > best_rate))) {
best_area = area
# Force a numeric value: awk would otherwise compare
# strings ("239.97" < "59.95"), keeping the wrong rate.
best_rate = rate + 0
best_mode = resolution " " rate
}
}
}
END { if (best_mode != "") print best_mode }
' <<< "$xrandr_query"
}
# No usable mode means the primary display is not connected (or exposes no
# valid modes): leave LightDM's default behavior untouched.
max_mode="$(get_max_mode "$PRIMARY_OUTPUT")"
if [[ -z "$max_mode" ]]; then
exit 0
fi
# Prepare the arguments that will turn off every other connected display.
turn_off_args=()
while IFS= read -r output_name; do
if [[ "$output_name" != "$PRIMARY_OUTPUT" ]]; then
turn_off_args+=(--output "$output_name" --off)
fi
done < <(awk '$2 == "connected" { print $1 }' <<< "$xrandr_query")
read -r resolution refresh_rate <<< "$max_mode"
xrandr --output "$PRIMARY_OUTPUT" --primary --mode "$resolution" \
--rate "$refresh_rate" --pos 0x0 --rotate normal "${turn_off_args[@]}"
exit 0
SCRIPT
# LightDM's standard drop-in directory: safe to create when a distribution
# does not ship it, since LightDM scans it by default.
[ -d /etc/lightdm/lightdm.conf.d ] || install -d -m 755 /etc/lightdm/lightdm.conf.d
install -m 644 /dev/stdin /etc/lightdm/lightdm.conf.d/95-greeter-display-setup.conf << 'CONF'
[Seat:*]
greeter-setup-script=/etc/lightdm/greeter-display-setup.sh
CONF
INSTALLER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment