You are not logged in.

#1 2021-02-05 14:50:45

squalou
Member
Registered: 2018-06-04
Posts: 112

[SOLVED] locking X session, unable to grab keyboard for screen 0

Hi,

I'm facing a weird issue since a few weeks (or is it months already ? can't really tell)

I'm using plain old tools to lock my desktop :

- slock as screen locker
- xss-lock to catch DPMS events
- xset to set DPMS  timings

# I run this at session startup :
xset s 300 dpms 300 300 300
xsslock slock

It has been working perfectly for years now.

My setup is : a laptop with a secondary screen attached over usb-c / display port

When I run manually 'slock' : it works fine.

When it's started by dpms event, it does not lock. After a few debugging I managed to see this error message :

unable to grab keyboard for screen 0
unable to grab mouse for screen 0

I wondered if it was related to slock, so I tried i3lock instead.

Same thing :

i3lock: Cannot grab pointer/keyboard

Weird thing is : 9 times out of 10, it fails. But sometimes it works.

For testing purpose, in a terminal I did set dpms to 5 seconds and started xss slock. Waited. And ... saw above errors.

Any idea is welcome to try to understand what happens / how to fix or workaround this.


Thank you !

Last edited by squalou (2021-02-05 17:57:18)

Offline

#2 2021-02-05 15:23:30

squalou
Member
Registered: 2018-06-04
Posts: 112

Re: [SOLVED] locking X session, unable to grab keyboard for screen 0

Sidenote,
right now I'm trying this workaround
- use xautolock -time 5 -locker slock  instead of xss-lock
- xset s 315 dpms 320 380 450

the idea being to not rely on dpms things. First attempt was successful. Unsatisfactory but worked.

I also tried xautolock with same timing as xset and it didn't work, that' s why I increased the xset timings a bit.

Last edited by squalou (2021-02-05 15:24:22)

Offline

#3 2021-02-05 15:28:56

seth
Member
Registered: 2012-09-03
Posts: 51,205

Re: [SOLVED] locking X session, unable to grab keyboard for screen 0

a laptop with a secondary screen attached over usb-c / display port

Does it work w/o the external display?

Online

#4 2021-02-05 17:12:54

squalou
Member
Registered: 2018-06-04
Posts: 112

Re: [SOLVED] locking X session, unable to grab keyboard for screen 0

No.
I did perform some additional tests at the moment to be sure : fresh reboot, nothing attached.
(to make sure it was not related to a plugged-in / plugged off / plugged-in etc.... weird situation)


xss-lock again, and xset s 5

First time it worked (I mean : wait 5 seconds, lock happens, enter password, unlock)
Second time : it failed with same message as stated before
3rd time : worked (?!)
4, 5, 6 : Failed

I'm not able to reproduce or guess the difference between work or fail.

Last edited by squalou (2021-02-05 17:47:46)

Offline

#5 2021-02-05 17:45:01

seth
Member
Registered: 2012-09-03
Posts: 51,205

Re: [SOLVED] locking X session, unable to grab keyboard for screen 0

If you bind xsslock to

xdotool key "XF86LogGrabInfo"

(or a script running it) you'll dump all passive and active grabs into the xorg log.
Any active grab would prevent further grabs (eg. from slock) so be your offender.

However, I worry something might be grabbing the entire server or reset input devices on dpms events.

As a mitigation you could delay the invocation of slock by a script that briefly sleeps (for eg. 0.5 seconds) before running slock.

Online

#6 2021-02-05 17:56:50

squalou
Member
Registered: 2018-06-04
Posts: 112

Re: [SOLVED] locking X session, unable to grab keyboard for screen 0

If I understood you well ... the culprit is probably : /usr/bin/xfce4-screensaver

Absolutely no idea why it's running. Smells like I didn't pay attention enough at previous xfce update maybe.

Killed it : works again like a charm !

pacman -R xfce4-screensaver
=> so I'm sure it won't be started by mistake again

Thank you !!

[  2761.296] (II) Printing all currently active device grabs:
[  2761.296] Active grab 0x800000 (xi2) on device 'Virtual core pointer' (2):
[  2761.296]       client pid 1110 /usr/bin/xfce4-screensaver 
[  2761.296]       at 2760910 (from active grab) (device thawed, state 1)
[  2761.296]       xi2 event mask for device 2: 0xf011c0
[  2761.296]       owner-events true, kb 1 ptr 1, confine 0, cursor 0x0
[  2761.296] Active grab 0x800000 (xi2) on device 'Virtual core keyboard' (3):
[  2761.296]       client pid 1110 /usr/bin/xfce4-screensaver 
[  2761.296]       at 2760910 (from active grab) (device thawed, state 1)
[  2761.296]       xi2 event mask for device 3: 0xfc700
[  2761.296]       owner-events true, kb 1 ptr 1, confine 0, cursor 0x0
[  2761.296] (II) End list of active device grabs

Last edited by squalou (2021-02-05 18:08:24)

Offline

Board footer

Powered by FluxBB