Jump to content

Quitting background apps


drfrot

Recommended Posts

I can't find how to quit an app running in the background (i.e. one that doesn't appear in the app switcher). Typing "quit" just shows the active dock/app-switcher apps that are actually easier to quit from there with a simple ⌘-Q keyboard stroke.

 

I'm looking for a way to quit helper apps, that are running in e.g. activity monitor, but don't appear in the app switcher.

 

I can find these apps easily enough using Alfred, but the "Actions" menu doesn't include a "Quit app" option.

 

Any suggestions?

 

Thanks

Link to comment

I can't find how to quit an app running in the background (i.e. one that doesn't appear in the app switcher). Typing "quit" just shows the active dock/app-switcher apps that are actually easier to quit from there with a simple ⌘-Q keyboard stroke.

 

I'm looking for a way to quit helper apps, that are running in e.g. activity monitor, but don't appear in the app switcher.

 

I can find these apps easily enough using Alfred, but the "Actions" menu doesn't include a "Quit app" option.

 

Any suggestions?

 

Thanks

 

This isn't support in Alfred by default but could potentially be done with a workflow that would parse the output of 'ps aux' to find applications running.

Link to comment

You can grab the top processes workflow. Look into how it works. You can search for processes (background apps), and then you can send kill signals to them. It does a bunch more than that, too.

 

Oof, that workflow's a bit over my head. Only just started with Alfred, not really had much Terminal experience, and find many of the workflows pretty baffling!

 

:wacko:

Link to comment

Well, if you want to do it the easy but not very extendable way, then you can just create a keyword like "qback" and link it to a script that would run "killall {query}" in bash. Now, that might not be the best way to do it because you'd have to get the name of the process exactly correct each time; also, killall is usually a bit, excuse the pun, overkill.

 

If you wanted to create it as a script filter, then you could do so by grabbing the Alfred Workflow library for whichever language you're most comfortable with, and then go about making it into a script filter. For instance, if you wanted to use php, then you'd grab David's PHP library (look at the pinned posts in the workflows help forum to find a list of all the libraries). So, say you want to create a specified list of background apps that you quit often, then you'd create a script filter (type 'php') with that keyword, argument required, space required...

<?php

require_once('workflows.php');
$w = new Workflows;

$apps = array('App 1', 'app2', 'helper3', 'app4'); // make sure that you get these perfectly correct with spaces and capitalization

foreach ($apps as $app) {
  $w->result( "$app", "$app", "Quit " . ucwords($app), "Kill background app: " . $app, "yes", $app);
}

echo $w->toxml();

Then, you'd attach it to a script action (language: bash) with the code

kill "{query}"

That would be it. In order to add new applications to quit, you'd just add them to the "apps" array in the script filter.

 

So, that's one way to do it. However, if you want to make it so that you can just quit any (backgrounded) app without entering them into that array, then you'd use the workflow that I mentioned in my previous post because that's one of its features. If you just want to control the output, then it'd be best to do it the way that I explained here.

 

Note: the code is untested, so there might be a bug or two.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...