Created
December 10, 2012 14:38
-
-
Save alonecuzzo/4250902 to your computer and use it in GitHub Desktop.
Quit Adium After 15 minutes of Idle Time
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
global quit_after, check_every | |
set quit_after to 900 | |
set check_every to 10 | |
display dialog "Check is performed every " & check_every & " seconds. Adium will be quit after " & quit_after & " seconds of system inactivity." | |
on reopen | |
display dialog "Check is performed every " & check_every & " seconds. Adium will be quit after " & quit_after & " seconds of system inactivity." | |
end reopen | |
on idle | |
set idletime to do shell script "echo $((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))" | |
if (idletime as integer) > quit_after then | |
tell application "System Events" | |
if ((name of processes) contains "Adium") then | |
tell application "Adium" to quit | |
end if | |
end tell | |
end if | |
return check_every | |
end idle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment