Created
January 20, 2021 07:12
-
-
Save maxpoletaev/f0db264286f9d7d1b62c2564bc1023e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
KEY_CODE=55 # Command Key | |
MAX_IDLE=30 | |
while true; do | |
idle=`ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'` | |
echo "Current idle: $idle" | |
if [[ $idle > $MAX_IDLE ]]; then | |
osascript -e "tell application \"System Events\" to key code $KEY_CODE" | |
echo "key pressed" | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment