Last active
October 3, 2015 15:25
-
-
Save connordavison/0a613ec8a85a6276e57a to your computer and use it in GitHub Desktop.
Execute command if idle
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 | |
# | |
# Execute a command if the user is idle for a specified period of time | |
# Requires: xprintidle | |
# Usage: if-idle IDLE_MIN IDLE_COMMAND [NOT_IDLE_COMMAND] | |
# | |
IDLE_MIN=$1 | |
IDLE_TIME=$(xprintidle) | |
IDLE_COMMAND=$2 | |
NOT_IDLE_COMMAND=$3 | |
[ "$IDLE_MIN" -lt "$IDLE_TIME" ] && $IDLE_COMMAND || $NOT_IDLE_COMMAND; | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment