I posted this a couple of weeks ago before my host had its little meltdown.
One of my friends has a problem with a printer driver that hangs when she tries to shutdown or restart her Mac. She won't let me try to fix it, and the [Apple][Option][Escape] force-quit dialog doesn't show the background application. She's gotten into the habit of running the Activity Monitor and using it to quit the printer driver before she restarts and that's just a pain in the ass.
So she asked me to come up with something better.
Since I had no access to her computer and she couldn't tell me the name of the printer driver, I couldn't just knock out a quick script to quit it. I had to write an all-purpose app-quitting script.
This is the script that I came up with:
(Your web browser may add line-breaks that you need to remove)
tell application "Finder"
set psNames to (name of application processes) as list
set app2Kwit to (choose from list psNames) as text
end tell
tell application app2Kwit
quit
end tell
When run, the script will display a list of all running applications that the current user has privileges for. Selecting an application from the list will send a quit command to that application. It's a little faster and easier than dealing with the Activity Monitor with its complicated interface.
A nice thing about the Quick Quitter script is that the application-list is limited to processes owned by the user so unless someone is logged in as root it can't be misused to quit an important system task.
While I was fiddling, I realized that I could easily change the code to make the script even more failsafe by only showing visible applications. It might come in handy for those friends who routinely use [Apple][Option][Escape] unnecessarily to quit programs that aren't misbehaving (you know who you are). That script looks like this:
tell application "Finder"
set psNames to (name of application processes whose visible is true) as list
set app2Kwit to (choose from list psNames) as text
end tell
tell application app2Kwit
quit
end tell
Finally, there's one more obvious variation, though I have to add a note of Caution that this one actually kills applications using a UNIX shell script and it may leave a computer unstable. If you use the Quick Killer script, below, you should restart your Mac afterwards.
tell application "Finder"
set psNames to (name of application processes whose visible = true) as list
set app2Kwit to (choose from list psNames) as text
end tell
do shell script "killall -9 " & app2Kwit
The Quick Killer script is useful enough that I put the applet in my Dock for easy access. Previously, I had been going to the Terminal to kill misbehaving apps. It's a nice time saver for me, but unless you're constantly experimenting like I am, you probably wouldn't need it.
Comments
No comments have been added yet. Be the first to comment...
Add a New Comment