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.