Created
October 19, 2023 09:55
-
-
Save eze-kiel/92de81bb43a1fa895b28b26f653cea7d to your computer and use it in GitHub Desktop.
Script to detect activity on the computer (keyboard/mouse)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
state="active" | |
threshold=10000 | |
while true; do | |
sleep 1 | |
idle=$(xprintidle) | |
if [[ "$idle" -lt "$threshold" && "$state" != "active" ]] ; then | |
state="active" | |
echo "$(date) - new activity started" | |
continue | |
fi | |
if [[ "$idle" -ge "$threshold" && "$state" == "active" ]]; then | |
state="inactive" | |
echo "$(date) - stopped activity" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment