Discussion:
Bug#789413: xtrlock: "Cannot open display" when called from /lib/systemd/system-sleep
(too old to reply)
JJ Vens
2015-06-20 17:50:02 UTC
Permalink
Package: xtrlock
Version: 2.7
Severity: normal

Dear Maintainer,

I have the following contents in the file /lib/systemd/system-sleep
The file is owned by root and executable.

#!/bin/bash

if [ "$1 $2" == "pre suspend" ]
then
DISPLAY=":0.0" su myusername -c "xtrlock" &
fi

This should lock my screen before entering system suspend. It used to work
as intended, but after the last upgrade my screen isn't locked anymore.
Using journalctl I found the following log entry:

Jun 19 19:53:40 legend systemd-sleep[11810]: xtrlock (version 2.5): cannot open display

When I run the file as root, e.g. `sudo /lib/systemd/system-sleep/lock-screen`
the screen is locked as expected. For some reason, display :0 is not
available when the system is suspended. As noted earlier, this way of
locking the screen was working before the upgrade.

Kind regards,
JJ

-- System Information:
Debian Release: stretch/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.0.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages xtrlock depends on:
ii libc6 2.19-18
ii libx11-6 2:1.6.3-1

xtrlock recommends no packages.

xtrlock suggests no packages.

-- no debconf information
--
To UNSUBSCRIBE, email to debian-bugs-dist-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Matthew Vernon
2015-06-23 14:20:03 UTC
Permalink
tags 789413 moreinfo
quit

Hi,
Post by JJ Vens
I have the following contents in the file /lib/systemd/system-sleep
The file is owned by root and executable.
DISPLAY=":0.0" su myusername -c "xtrlock" &
Are you sure DISPLAY is set appropriately, and/or being passed through
to xtrlock?
Post by JJ Vens
Jun 19 19:53:40 legend systemd-sleep[11810]: xtrlock (version 2.5): cannot open display
This is what happens if XOpenDisplay(0) returns NULL, which means that
the program could not connect to the display specified in $DISPLAY.

I think it is very unlikely that this is a bug in xtrlock.
Post by JJ Vens
When I run the file as root, e.g. `sudo /lib/systemd/system-sleep/lock-screen`
the screen is locked as expected. For some reason, display :0 is not
available when the system is suspended. As noted earlier, this way of
locking the screen was working before the upgrade.
I suspect, therefore, that systemd is at fault?

Regards,

Matthew
--
To UNSUBSCRIBE, email to debian-bugs-dist-***@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact ***@lists.debian.org
Chris Lamb
2019-07-21 18:40:01 UTC
Permalink
Hi,
xtrlock: "Cannot open display" when called from /lib/systemd/system-sleep
It is likely that the DISPLAY variable is being masked from the final xtrlock binary.

$ DISPLAY=":0.0" su myusername -c "xtrlock" &

Can you try:

$ su myusername -c "env DISPLAY=:0.0 xtrlock" &

… or similar?


Regards,
--
,''`.
: :' : Chris Lamb
`. `'` ***@debian.org 🍥 chris-lamb.co.uk
`-
Loading...