Created
March 22, 2011 16:52
-
-
Save krl/881556 to your computer and use it in GitHub Desktop.
ii away scriptlet
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 | |
THRESHOLD=1000 | |
TEMP_FILE=/tmp/.ii-is-away | |
let time=$(date +%s)-$(stat -c%X ~/.ii-active) | |
function sendall { | |
for server in ~/irc/* | |
do | |
if [ ! -h "$server" ] | |
then | |
echo $1 > $server/in | |
fi | |
done | |
} | |
if [ "$time" -gt "$THRESHOLD" ] | |
then | |
if [ ! -f "$TEMP_FILE" ] | |
then | |
sendall "/a idle" | |
touch $TEMP_FILE; | |
fi | |
else | |
if [ -f "$TEMP_FILE" ] | |
then | |
sendall "/a" | |
rm $TEMP_FILE; | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment