Time ticking despite of TRACK_INACTIVE: False and locked screen

Asked by Nikita Smirnov

Hello and thanks for maintaining this app!

I have Ubuntu 19.10, X11 user session, the TRACK_INACTIVE is False for the user.
When user locks screen (screen went black), all works fine, but only up to the moment when screen awakes (mouse moved or key pressed). From this moment the user session is considered active. User does not unlock screen, only touched the mouse.

Here is the log pieces (the user name is rightrat):

1. Locked screen, all right:
2020-04-09 19:53:21.225163: ---=== start isUserActive for "rightrat" ===---
2020-04-09 19:53:21.225249: supported session types: ['x11', 'wayland', 'mir']
2020-04-09 19:53:21.226372: user stats, state: active, idleState: True
2020-04-09 19:53:21.226502: ---=== start cacheUserSessionList for "rightrat" ===---
2020-04-09 19:53:21.227002: got 1 sessions, start loop
2020-04-09 19:53:21.227132: session already cached: 13
2020-04-09 19:53:21.227222: ---=== finish cacheUserSessionList for "rightrat" ===---
2020-04-09 19:53:21.228338: got session - type: x11, VTNr: 2, state: active, idle: True
2020-04-09 19:53:21.228473: session 13 inactive
2020-04-09 19:53:21.228571: ---=== finish isUserActive: False ===---

2. User touched the mouse (but did not enter the password and did not unlock screen):
2020-04-09 19:55:48.893139: ---=== start isUserActive for "rightrat" ===---
2020-04-09 19:55:48.893224: supported session types: ['x11', 'wayland', 'mir']
2020-04-09 19:55:48.894238: user stats, state: active, idleState: False
2020-04-09 19:55:48.894348: ---=== start cacheUserSessionList for "rightrat" ===---
2020-04-09 19:55:48.894785: got 1 sessions, start loop
2020-04-09 19:55:48.894917: session already cached: 13
2020-04-09 19:55:48.895018: ---=== finish cacheUserSessionList for "rightrat" ===---
2020-04-09 19:55:48.896162: got session - type: x11, VTNr: 2, state: active, idle: False
2020-04-09 19:55:48.896298: session 13 active
2020-04-09 19:55:48.896395: ---=== finish isUserActive: True ===---

And from this moment user considered active even when screen blanks afterwards.

If user clicks then "log in as another user", he became inactive again because state changes from active to online:
2020-04-09 20:10:26.343805: ---=== start isUserActive for "rightrat" ===---
2020-04-09 20:10:26.343901: supported session types: ['x11', 'wayland', 'mir']
2020-04-09 20:10:26.344693: user stats, state: online, idleState: False

I don't understand much in dbus etc, but may be there is some other signs of the fact that screen is locked now, on which app can rely on?

Question information

Language:
English Edit question
Status:
Solved
For:
Timekpr-nExT Edit question
Assignee:
Eduards Bezverhijs Edit question
Solved by:
Eduards Bezverhijs
Solved:
Last query:
Last reply:
Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#1

I have noticed that in my previous testing, but it is working the best it currently can :) I'll explain.

timekpr-next uses DE (gnome,kde,budgie,cinamon,...) agnostic standards / controls to work. The common thing nowadays is systemd, timekpr use it for everything related to users and sessions.
SessionIdleState You see in the logs, comes from login1 (systemd user / seat management thing) which seems to be broadly adopted. I have looked at its dbus methods a lot, there is nothing much else to check for idle state.
I guess every DE should set the state of session somewhat the same and from user perspective, screen is on or not while it's locked does not matter, it is still locked and he can not work. But as You discovered, once mouse is moved, session is not idle anymore. I do not know why exactly, but I guess techically it's not, because mouse was moved.

The only thing I imagine, is to try to connect to all possible screensaver or screenlock thing every DE provides, which frankly, is not the right way, but can be the only way currently to achieve the result at least for major players. KDE has its own thing, Gnome too, then comes the rest of multitude DEs with their own thing.
I hope I'm wrong and I'll check whether they all have something in common, maybe I can use that to improve things about locking. Previously I have checked this a little, was not on priority back then, but it seemed pretty diverse in screen locking.

I'll check, can't promise anything...

Revision history for this message
Nikita Smirnov (nikita-smirnov) said :
#2

Thank you for prompt reply.

If I understood correctly, there are two different states: one for system (is Idle or not Idle), and other for user serssion (is active or not). I found (and that's in logs) that user session is active even when he locked screen. And it remains "active" until someone presses "Log as another user" button. After that, session becomes "online". I wrote this because you said that session is not idle since mouse moved -- but from perspective of my system, user session was active even when he locks the screen and it went blank; the only thing that changed is idle state of whole system. So, if no one cicks "Log as another user", the user's session is never becomes inactive, just system idle state changes (the system becomes "not idle" after mouse moved or key pressed).

So there probably is a bug in logind or other component of OS/systemd or something. It would be good to post bugreport on this (but I can't understand where to post It, and how to reproduce problem nore directly, not via timekpr; although I understand python and probably can write some test script on this). Ind even if that's not a bug, there probably will be some clarification.

Or, alternatively, there is another proper way to decide if user is active or not.

I agree that it is no good to check for different screensavers activity (but for some time it may do as workaround), especially when there is the "right" way.

Anyway, thank you, and I hope you'll find something on this case.

Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#3

I have found a hackish not-a-good-but-rather-acceptable way to accomplish exactly what's needed. Yey :)

I'll see whether I can make this work in actual timekpr and let's see which DEs work. I'll let You know whether that works, but be prepared to install beta, as this will need more testing.

Revision history for this message
Nikita Smirnov (nikita-smirnov) said :
#4

Good! I'll be happy to help.

Revision history for this message
Best Eduards Bezverhijs (mjasnik) said :
#5

Please install beta version of timekpr, please report back whether it works. Please read the latest announcement about quirks for certain DEs.

Revision history for this message
Nikita Smirnov (nikita-smirnov) said :
#6

Fine, it works for me, thank you!

P.S.
I absolutely agree with you on this: "screensaver detection is a client responsibility, thus can be faked by clever program user can write, but if user can write a piece of code that actually connects to timekpr DBUS, understand it's logic / verification requests, etc. and can fake results based on client / server interaction, maybe this user should not have timekpr enforced on him in the first place :)"

Revision history for this message
Nikita Smirnov (nikita-smirnov) said :
#7

Thanks Eduards Bezverhijs, that solved my question.