Skip to content

Instantly share code, notes, and snippets.

@alonecuzzo
Created December 10, 2012 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alonecuzzo/4250902 to your computer and use it in GitHub Desktop.
Save alonecuzzo/4250902 to your computer and use it in GitHub Desktop.
Quit Adium After 15 minutes of Idle Time
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