Screen locking fails on Suspend/Resume for laptop lid-switch

Bug #1783895 reported by Chris Rainey
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Xfce4 Session
Confirmed
Medium
xfce4-session (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Using a pure install of the "xfce4" and "xfce4-power-manager" packages after a clean install of Ubuntu 18.04 LTS does not lock the screen when closing a laptop lid without manually adding the following property to the local or global xfconf database(/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml):

<property name="LockCommand" type="string" value="xscreensaver-command -lock"/>

This property is undiscoverable and not well documented, if at all.

There was a patch to add this property back in 2015 @ https://git.xfce.org/xfce/xfce4-session/commit/settings/xfce4-session.xml?id=570093ffafa8a6226ce9dd0ee29e9e64539d4bc9, but it does not appear to be in the current Ubuntu source.

Manually adding this prpoerty is accomplished by the following command:

$xfconf-query -c xfce4-session -p /general/LockCommand -s 'xscreensaver-command -lock' -v -n -t string

Without this parameter and a named running screen locking daemon(XScreenSaver by default), the system will Suspend---but, not be locked upon Resume when triggered by a laptop lid-switch.

Please add or patch the Ubuntu version to provide this basic functionality as "systemd-logind.service" is not overriding by default:

$ systemd-inhibit --list
     Who: NetworkManager (UID 0/root, PID 936/NetworkManager)
    What: sleep
     Why: NetworkManager needs to turn off networks
    Mode: delay

     Who: ModemManager (UID 0/root, PID 895/ModemManager)
    What: sleep
     Why: ModemManager needs to reset devices
    Mode: delay

     Who: UPower (UID 0/root, PID 1564/upowerd)
    What: sleep
     Why: Pause device polling
    Mode: delay

     Who: xfce4-power-manager (UID 1000/chris, PID 1614/xfce4-power-man)
    What: handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch
     Why: xfce4-power-manager handles these events
    Mode: block

4 inhibitors listed.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: xfce4-session 4.12.1-3ubuntu3
ProcVersionSignature: Ubuntu 4.15.0-29.31-generic 4.15.18
Uname: Linux 4.15.0-29-generic x86_64
ApportVersion: 2.20.9-0ubuntu7.2
Architecture: amd64
CurrentDesktop: XFCE
Date: Thu Jul 26 16:00:40 2018
InstallationDate: Installed on 2018-06-23 (33 days ago)
InstallationMedia: Ubuntu 18.04 LTS "Bionic Beaver" - Release amd64 (20180426)
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: xfce4-session
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
In , Pf4public (pf4public) wrote :

Xfce4-power-manager does not catch lid events.
acpi_listen does show lid events.
UPower does catch lid events.
Xfce4-power-manager --debug gives no output on lid events.
It has settings for lid events, but they are ignored as no event catched.
It does appropriate actions upon suspend and poweroff keys, but not lid.
What is wrong here?
Thanks in advance.

Revision history for this message
In , Simon Naunton (snaunton) wrote :

Have you tried:

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/logind-handle-lid-switch -n -t bool -s false

Revision history for this message
In , Pf4public (pf4public) wrote :

Of course! But this does not help.
Since my system does not even have logind, this might be irrelevant setting though.
But anyway thanks for your answer!

Revision history for this message
In , Ali-b (ali-b) wrote :

Try to monitor the bus to see if upower is effectively sending the signal to the power manager, using the following command.

dbus-monitor --system "type='signal',sender='org.freedesktop.UPower'"

Revision history for this message
In , Pf4public (pf4public) wrote :

Thanks for your reply.
Activating and deactivating lid button gives me these events:
signal time=1510773931.714558 sender=:1.20 -> destination=(null destination) serial=3144 path=/org/freedesktop/UPower; interface=org.freedesktop.UPower; member=Changed
signal time=1510773932.546623 sender=:1.20 -> destination=(null destination) serial=3145 path=/org/freedesktop/UPower; interface=org.freedesktop.UPower; member=Changed
One for lid-close event, the other for lid-open respectively with ever increasing serial.
Is there anything else I can do to identify the cause of this issue?

Revision history for this message
In , Paul Ni (nikulinpi-gmail) wrote :

I'm also having this issue.

Upower does register LID events

signal time=1531921145.698725 sender=:1.10 -> destination=(null destination) serial=748 path=/org/freedesktop/UPower; interface=org.freedesktop.UPower; member=Changed

But I have nothing in xfpm debug output

To my memory, suspend by lid worked few times for me.

Revision history for this message
In , Paul Ni (nikulinpi-gmail) wrote :

My system.

Gentoo
Elogind
upower-pm-utils
No systemd

Revision history for this message
In , Paul Ni (nikulinpi-gmail) wrote :

Debug output https://pastebin.com/bsn97Vwq

baybal@xps ~ $ xfconf-query -c xfce4-power-manager -vl
/xfce4-power-manager/blank-on-battery 2
/xfce4-power-manager/brightness-on-battery 60
/xfce4-power-manager/brightness-switch 0
/xfce4-power-manager/brightness-switch-restore-on-exit 0
/xfce4-power-manager/general-notification true
/xfce4-power-manager/handle-brightness-keys true
/xfce4-power-manager/hibernate-button-action 2
/xfce4-power-manager/inactivity-on-battery 176
/xfce4-power-manager/inactivity-sleep-mode-on-battery 1
/xfce4-power-manager/lid-action-on-ac 0
/xfce4-power-manager/lid-action-on-battery 1
/xfce4-power-manager/lock-screen-suspend-hibernate false
/xfce4-power-manager/logind-handle-lid-switch false
/xfce4-power-manager/power-button-action 1
/xfce4-power-manager/presentation-mode false
/xfce4-power-manager/show-panel-label 3
/xfce4-power-manager/show-tray-icon true
/xfce4-power-manager/sleep-button-action 1

baybal@xps ~ $ xfce4-power-manager --dump
---------------------------------------------------
       Xfce power manager version 1.6.1
With policykit support
Without network manager support
---------------------------------------------------
Can suspend: True
Can hibernate: True
Authorised to suspend: True
Authorised to hibernate: True
Authorised to shutdown: True
Has battery: True
Has brightness panel: True
Has power button: True
Has hibernate button: True
Has sleep button: True
Has LID: True

Revision history for this message
In , Paul Ni (nikulinpi-gmail) wrote :

sys-power/upower-pm-utils 0.9.23-r2

xfce 4.12

polkit 0.113

pm-utils 1.4.1

Revision history for this message
Chris Rainey (ckrzen) wrote :
Revision history for this message
In , Chris Rainey (ckrzen) wrote :

I solved this yesterday on Ubuntu 18.04.1:

Using a pure install of the "xfce4" and "xfce4-power-manager" packages after a clean install of Ubuntu 18.04 LTS does not lock the screen when closing a laptop lid without manually adding the following property to the local or global xfconf database(/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml):

<property name="LockCommand" type="string" value="xscreensaver-command -lock"/>

This property is undiscoverable and not well documented, if at all.

There was a patch to add this property back in 2015 @ https://git.xfce.org/xfce/xfce4-session/commit/settings/xfce4-session.xml?id=570093ffafa8a6226ce9dd0ee29e9e64539d4bc9, but it does not appear to be in the current Ubuntu source.

Manually adding this prpoerty is accomplished by the following command:

$xfconf-query -c xfce4-session -p /general/LockCommand -s 'xscreensaver-command -lock' -v -n -t string

Without this parameter and a named running screen locking daemon(XScreenSaver by default), the system will Suspend---but, not be locked upon Resume when triggered by a laptop lid-switch.

Please add or patch the Ubuntu version to provide this basic functionality as "systemd-logind.service" is not overriding by default:

$ systemd-inhibit --list
     Who: NetworkManager (UID 0/root, PID 936/NetworkManager)
    What: sleep
     Why: NetworkManager needs to turn off networks
    Mode: delay

     Who: ModemManager (UID 0/root, PID 895/ModemManager)
    What: sleep
     Why: ModemManager needs to reset devices
    Mode: delay

     Who: UPower (UID 0/root, PID 1564/upowerd)
    What: sleep
     Why: Pause device polling
    Mode: delay

     Who: xfce4-power-manager (UID 1000/chris, PID 1614/xfce4-power-man)
    What: handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch
     Why: xfce4-power-manager handles these events
    Mode: block

4 inhibitors listed.

https://bugs.launchpad.net/ubuntu/+source/xfce4-session/+bug/1783895

Changed in xfce4-session:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Paul Ni (nikulinpi-gmail) wrote :

Installing latest upower solved my issues.

It appears that upower-pm-utils form of 0.9 does not have the new lid events api.

Revision history for this message
Chris Rainey (ckrzen) wrote :

OK, just circling back around to this as of today, 02/07/2019:

It appears that just by having Xscreensaver installed, although disabled in the autostart items of the session manager, can inhibit the use of the other items further down in the /usr/bin/xflock4 script(i.e. slock). So . . . after making sure that 'logind-handle-lid-switch' is set to 'false'(unchecked) and removing(purge) 'xscreensaver', I am getting good results with having 'slock' screen-locking at lid-events on my ThinkPad T450.

Revision history for this message
markling (markling) wrote :

I found it necessary to lock+suspend the screen before closing the lid. So I did it with a script tied to the keyboard shortcut CTRL+SUPER+DELETE:

https://askubuntu.com/a/1162665/297529

Revision history for this message
3t0g0 (freetogo) wrote :

#14 is the only workable workaround for this bug.

However, is there any chance to do this automatically? Can we run "xrandr --auto" immediately after unlocking.

Revision history for this message
3t0g0 (freetogo) wrote :

Will something like below work? If not, how to improve it?

dbus-monitor --system "type='signal',sender='org.freedesktop.login1',path='/org/freedesktop/login1/seat/seat0',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'" | grep --line-buffered "ActiveSession" | while read line; do xrandr --auto; done

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in xfce4-session (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.