Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ################################################
- # Monitor X idle time. Lock screen when idle.
- IDLETIME="5" # in minutes
- ################################################
- function getidle () {
- # Get idle in seconds instead of ms
- echo $(( $(xprintidle) / 1000))
- }
- function lockscreen () {
- # check for running instance of slimlock
- if [[ $(pgrep slimlock) ]]
- then
- echo "Existing instance detected."
- else
- slimlock
- fi
- }
- # minutes to seconds
- IDLE=$(($IDLETIME * 60))
- while true
- do
- IDLESEC=$(getidle)
- if (( "$IDLESEC" >= "$IDLE" ))
- then
- lockscreen
- # Reset IDLESEC to force full sleep period
- IDLESEC=0
- fi
- sleep $(( $IDLE - $IDLESEC ))
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement