Created
February 17, 2012 02:31
-
-
Save fancyremarker/1849998 to your computer and use it in GitHub Desktop.
Set of scripts to kill Things after 5 minutes of keyboard/mouse idle
This file contains hidden or 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/sh | |
# idlequit <application name> <timeout> | |
# Quits application if system has been idle for greater than timeout. | |
if [ $# -ne 2 ]; then | |
echo "Usage: idlequit <application name> <timeout>" >&2 | |
exit 1 | |
fi | |
if [ `/usr/local/bin/idletime` -gt ${2} ]; then | |
/usr/local/bin/pgrep ${1} > /dev/null && osascript -e "tell application \"${1}\" to quit" | |
fi |
This file contains hidden or 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/sh | |
echo $((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000)) |
This file contains hidden or 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/sh | |
# install.sh | |
cp idlequit /usr/local/bin/ | |
chmod 755 /usr/local/bin/idlequit | |
cp idletime /usr/local/bin/ | |
chmod 755 /usr/local/bin/idletime | |
cp local.idlequit.Things.plist ~/Library/LaunchAgents/ | |
launchctl load -w ~/Library/LaunchAgents/local.idlequit.Things.plist |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>local.idlequit.Things</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/local/bin/idlequit</string> | |
<string>Things</string> | |
<string>240</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>KeepAlive</key> | |
<false/> | |
<key>StartInterval</key> | |
<integer>120</integer> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To install, clone and run
sh install.sh
. Can be easily edited to work for other applications.