0

I am working on a little script that logs what the user is actively working on (on the desktop), and thus needs to know if the user is active or idle. The script is run as root via crontab every 1 minute.

On the machines where the script is being deployed, I have set the screen lock to kick in after 5 minutes, and this is a fair threshold.

So my idea was to check if the user is logged in, or maybe if the screen lock is active, but I can't seem to find any way to achieve this.

How can I do this? Is there any other method for checking if the user is idle or not?

I am running CentOS Linux release 7.3.1611.

0

I don't know how to find out this information directly, but you can find it out indirectly by listening for lock/unlock events on DBUS. You can find a way how to do it in other questions, for example Run script on screen lock/unlock

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.