Created
May 9, 2021 15:21
-
-
Save ffub/fb1364c11ca4f64bccb935d620ee3371 to your computer and use it in GitHub Desktop.
Quit all applications on a Mac, with the option to leave the front most open
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
-- get list of open apps | |
tell application "System Events" | |
set allApps to displayed name of (every process whose background only is false) as list | |
set activeApp to name of first application process whose frontmost is true | |
set exclusions to {"Finder", "LaunchBar"} | |
end tell | |
set {button returned:myQuery} to display dialog "Which applications do you want to quit?" with title "Quit All" with icon caution buttons {"Cancel", "Quit All", "Keep Active Open"} | |
if myQuery is "Quit All" then | |
-- quit each unless exclusion | |
repeat with thisApp in allApps | |
set thisApp to thisApp as text | |
if thisApp is not in exclusions then | |
tell application thisApp to quit | |
end if | |
end repeat | |
else if myQuery is "Keep Active Open" then | |
-- quit each unless exclusion | |
copy activeApp to end of exclusions | |
repeat with thisApp in allApps | |
set thisApp to thisApp as text | |
if thisApp is not in exclusions then | |
tell application thisApp to quit | |
end if | |
end repeat | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment