Created
February 8, 2017 15:16
-
-
Save haircut/59e6e3f690c95f38f38ff38c2cfaa3da to your computer and use it in GitHub Desktop.
Closes all running apps, excluding those found in a customizable whitelist
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/sh | |
# Quit apps command | |
read -r -d '' OSASCRIPT_COMMAND <<EOD | |
set white_list to {"Finder"} | |
tell application "Finder" | |
set process_list to the name of every process whose visible is true | |
end tell | |
repeat with i from 1 to (number of items in process_list) | |
set this_process to item i of the process_list | |
if this_process is not in white_list then | |
try | |
tell application this_process | |
quit saving no | |
end tell | |
on error | |
# do nothing | |
end try | |
end if | |
end repeat | |
EOD | |
/usr/bin/osascript -e "${OSASCRIPT_COMMAND}" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment