lightdm is running an X server. How to find out which $DISPLAY setting it is listening to?

Background: I'm debugging what appears like DPMS issues between a monitor and a GPU (proprietary nvidia driver) that usually work well with each other, except when they don't (monitor does not wake up from stand-by after a few hours idle). xset dpms force o{ff,n} is useful, but only when I know which $DISPLAY I'm on. When a graphical session is running, this is no problem (usually just :0), but lightdm doesn't seem to stick to this convention, and DISPLAY=:0 spoofing from tty or ssh returns unable to open display ":0" errors.

  • 1
    note: probably not the case here, but lightdm greeter can run on wayland (without X11) just as well. As said, unlikely your problem here. Commented Mar 30, 2022 at 10:42
  • 1
    does ls /tmp/.X11-unix help? Commented Mar 30, 2022 at 10:42
  • Thanks for the pointer. /tmp/.X11-unix/ contains the socket X0, and ps aux reports /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch; in either case it makes no difference if a user session is running or not. Commented Mar 31, 2022 at 13:47

1 Answer 1


It turns out I have the same exact problem (with DPMS and even plain screen blanking, proprietary NVidia driver, lightdm, but also from within a logged in session), and I just found a solution :

copy the xauth file from Xorg so you can read it, set the XAUTHORITY variable to point to that file, and set the display to the display found in the Xauth file (unix:0 in my case).

Full run down :

~ $ ssh somecomputer
~ $ ps ax | grep lightdm
  40420 ?        SLsl   0:00 /usr/sbin/lightdm
  62985 tty7     Ssl+   0:00 /usr/lib/xorg/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
  63075 ?        Sl     0:00 lightdm --session-child 18 21
  63192 ?        Ssl    0:00 /usr/sbin/lightdm-gtk-greeter
  63240 ?        S      0:00 lightdm --session-child 14 21
  67141 pts/0    S+     0:00 grep lightdm
~ $ sudo su
~ # cp /var/run/lightdm/root/:0 /tmp/lightdmauth
~ # chmod a+r /tmp/lightdmauth
~ # exit
~ $ export XAUTHORITY=/tmp/lightdmauth
~ $ xauth -f /tmp/lightdmauth
xauth:  /tmp/lightdmauth not writable, changes will be ignored
Using authority file /tmp/lightdmauth
xauth> list
somecomputer/unix:0  MIT-MAGIC-COOKIE-1  5b35f44220224bef134a491dc3bxxxxx
xauth> exit
~ $ export DISPLAY=unix:0
~ $ xeyes &

and xeyes shows up over lightdm.

This documentation from Citrix helped me.

Now I still have to find how to setup this to wake up screens automatically. My idea (tested and works) is to run sxhkd to add a keyboard shortcut to lightdm to run a custom script we made that turns the display back to life (provided below as a bonus).

~ $ cat /usr/local/bin/fix-black-screen

# fix_black_screen
# Tries to wake up screen if disconnected due to deep sleep

if [ -n "$1" ]; then
  ssh "$1" $(basename $0)
  exit $?

# get the list of plugged-in monitors, regardless of whether they are connected
# or disconnected.

# When not showing in nvidia-settings, it looks like this in xrandr:
# DP-3 disconnected 2560x1440+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
# When showing in in nvidia-settings as disabled, it looks like this in xrandr:
# DP-3 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 600mm x 340mm

export DISPLAY=:0

outputs="`xrandr | grep 'connected' | cut -d ' ' -f 1`"

for attempt in {1..10}; do
    for output in $outputs ; do
        # we only try to re-enable the display if it shows as connected
        xrandr --current | grep -q "^$output connected"
        if [ "$?" -eq 1 ]; then
            echo "Output $output does not show as connected, will retry later ($attempt/10)."
        xrandr --output $output --preferred --dpi 96
        xdotool mousemove 0 0
        xrandr -q | grep -q "*"
        if [ $? -eq 0 ]; then
            echo "Fixed output $output"
    sleep 1

xset -dpms
xset dpms 600 1200 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .