You are not logged in.

#1 2019-07-06 21:42:47

sooqua
Member
Registered: 2014-11-11
Posts: 14

xss-lock and IdleAction break after first suspend with screen locked

Hello! So, my goal is to have the following actions take place on lack of user interaction:
1) Make a visual notification that the screen is about to be locked, in my case I copied and modified xss-lock's /usr/share/doc/xss-lock/dim-screen.sh
2) Lock the screen (I use physlock; I tried other lockers, but they didn't solve my problem)
3) Suspend the system
Of course, there should be a delay after each step, but I didn't include it here since it doesn't matter that much. Order matters.

I am using this to start xss-lock in my .xinitrc:

xset s 300 10
xss-lock -n ~/.scripts/sh/dim-screen.sh -l -- ~/.scripts/sh/transfer-sleep-lock-physlock.sh &

Here is the content of transfer-sleep-lock-physlock.sh, a slightly modified version of xss-lock's /usr/share/doc/xss-lock/transfer-sleep-lock-i3lock.sh:

#!/bin/bash

# Check for duplicate instances
if pidof physlock >/dev/null; then
    exit 0
fi

## CONFIGURATION ##############################################################

# Options to pass to physlock
physlock_options="-d -m"

###############################################################################

# We set a trap to kill the locker if we get killed, then start the locker and
# wait for it to exit. The waiting is not that straightforward when the locker
# forks, so we use this polling only if we have a sleep lock to deal with.
if [[ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]]; then
    kill_physlock() {
        pkill -xu $EUID "$@" physlock
    }

    # Set exit handler
    trap kill_physlock TERM INT

    # We have to make sure the locker does not inherit a copy of the lock fd
    physlock $physlock_options {XSS_SLEEP_LOCK_FD}<&-

    # Now close our fd (only remaining copy) to indicate we're ready to sleep
    exec {XSS_SLEEP_LOCK_FD}<&-

    # Wait for all instances of physlock to finish
    while kill_physlock -0; do
        sleep 0.5
    done
else
    # Start physlock and wait for it to finish
    physlock $physlock_options &
    wait

    # Set exit handler
    trap 'kill %%' TERM INT
fi

Two out of three tasks done!
Now I need to suspend the system after a delay bigger than that set with xset s. Uncomment and edit lines in /etc/systemd/logind.conf:

IdleAction=suspend
IdleActionSec=6min

I don't use any DE (just Awesome WM on a fresh Arch installation), so by default nothing is reporting my idle status to systemd-logind[1].
Thankfully, xss-lock does just that[2]:

Also, xss-lock manages the idle hint on the login session. The idle state of the session is directly linked to user activity as reported by X (except when the notifier runs before locking the screen). When all sessions are idle, the login manager can take action (such as suspending the system) after a preconfigured delay.

Here is the problem:

If I run

loginctl show-seat -p IdleHint

I get IdleHint=no, meaning that xss-lock updates the idle status for me, otherwise systemd-logind would consider me inactive, even if I'm active, and lock the screen after the specified delay (in my case 6 min)!
Then, if I do any of the following:

  • Run systemctl suspend

  • Close the lid of my laptop

  • Wait for screen to be locked and close the lid

The IdleHint is still no.
However, if I let my laptop go through all three steps, i.e. wait for systemd-logind to suspend the system after physlock has started, IdleHint changes to yes, even though the xss-lock process is still active. After that, my laptop goes to sleep every 6 minutes despite user activity.
I'm not very good at bash or Linux commands. I couldn't find anything interesting in journalctl. Could someone maybe probably show me a bunch of commands that could help to get closer to the core of the issue?
Any ideas would be much welcome. This is the second sleepless night I spent trying to fix this, and I just want my Linux to work as it should )`:

Last edited by sooqua (2019-07-07 00:11:04)

Offline

#2 2019-07-06 21:54:32

progandy
Member
Registered: 2012-05-17
Posts: 5,322

Re: xss-lock and IdleAction break after first suspend with screen locked

Do you use any display manager? Systemd doesn't handle idle well if you start a graphical session from a terminal session.

If you don't want a graphical manager you can try { ly ]

Last edited by progandy (2019-07-06 21:55:41)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#3 2019-07-07 00:09:49

sooqua
Member
Registered: 2014-11-11
Posts: 14

Re: xss-lock and IdleAction break after first suspend with screen locked

Ok, lightdm did the trick. It was updating IdleHint before I even started xss-lock! And is persistent between suspends. Didn't know display managers can do that, without DE. Thanks!
Btw, lightdm-webkit2-greeter is absolutely gorgeous!

Offline

#4 2019-07-07 06:59:06

progandy
Member
Registered: 2012-05-17
Posts: 5,322

Re: xss-lock and IdleAction break after first suspend with screen locked

sooqua wrote:

Ok, lightdm did the trick. It was updating IdleHint before I even started xss-lock! And is persistent between suspends. Didn't know display managers can do that, without DE. Thanks!
Btw, lightdm-webkit2-greeter is absolutely gorgeous!

The one thing you really need a display manager for is setting the Session type to wayland or x11. With a console session systemd uses internal logic to detect user activity, and doesn't rely on the idle hint which can be annoying since it doesn't work then.

Last edited by progandy (2019-07-07 06:59:52)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

Board footer

Powered by FluxBB