Jump to content

[SOLVED] Quit all except [named app]


Recommended Posts

I've seen variations of this question elsewhere, but not exactly what I'm looking for.

 

I've been using Alfred's 'Quit All Apps' to tidy up open applications at the end of my study sessions.  But I have a certain app (Tick Tick) that I need to stay open in the background even when it receives a quit command.  I'm a complete novice as far as workflows are concerned but what I'd like to do is either i) create a custom workflow that replicates Alfred's 'Quit All Apps' command, but with an exception or ii) find a way to edit the 'Quit All Apps' command so that it excludes Tick Tick (not sure if this is even possible).  I'd like to tricker this workflow with a keyword.

 

Any help gratefully received.  

Link to comment

Welcome @bubbabr,

 

On 6/6/2019 at 11:50 PM, bubbabr said:

stay open in the background even when it receives a quit command.

 

That‘s not possible. If an app gets a quit command, it means you want it to quit. This is handled by the system; it’s not optional.

 

On 6/6/2019 at 11:50 PM, bubbabr said:

create a custom workflow that replicates Alfred's 'Quit All Apps' command, but with an exception

 

This is the right solution. The trick is ask the system for a list of all apps, remove the one we want, then tell all apps on the list to quit. Here’s a ready-made Workflow. It’s untested, but should work.

 

Released it as a Workflow:

 

Edited by vitor
Added link to new Workflow
Link to comment

Hi! Great, I was looking for such an solution and I'm glad I've found such a "fresh" one. I'm not into coding at all, so what I didn't find out by trial an error is: where do I have to write in the name of the App that should stay alive? (I want Firefox to stay).

 

help at this gratefully received

Link to comment

Thanks for the fast answer. OK, I found that an made a keep_alive with value Firefox and deleted the one with the value Tik Tok.

Than with alt+space and Keyword "fire" everything showed up like expected, but didn't execute

image.png.12975a698f03c31199b0911e9f227a72.pnghitting return or klicking the higlighted with the mouse didn't produce a result.

Is there something I forgot to do?

Link to comment
5 hours ago, vitor said:

Welcome @bubbabr,

 

 

That‘s not possible. If an app gets a quit command, it means you want it to quit. This is handled by the system; it’s not optional.

 

 

This is the right solution. The trick is ask the system for a list of all apps, remove the one we want, then tell all apps on the list to quit. Here’s a ready-made Workflow. It’s untested, but should work.

 

Hi vitor, thanks for the reply.  Doesn't work for me unfortunately - the workflow executes, but closes all apps including Tick Tick (nice bonus is that the workflow closes open Finder windows, another thing I was trying to work out). Also, side side question - if Tick Tick is listed in the variables, what's the point of requiring an argument to go with the Highlander keyword?  Why wouldn't the workflow execute without the need for a keyword?

Link to comment
5 hours ago, bubbabr said:

the workflow executes, but closes all apps including Tick Tick

 

Open Tick Tick. Open the Script Editor app, paste this code, run it (⌘R), and post the result.

tell application "System Events" to return (name of every process where background only is false)

You shouldn’t run stray code from the internet without understanding it, but that should be pretty clear. What it will do is return a list of every running app. It’s possible that `Tick Tick` is calling itself by a different name, and it should show there.

 

5 hours ago, bubbabr said:

side question - if Tick Tick is listed in the variables, what's the point of requiring an argument to go with the Highlander keyword?

 

That’s the default and I forgot to change it. No argument is required.

Link to comment
10 hours ago, palatinatemike said:

hitting return or klicking the higlighted with the mouse didn't produce a result.

Is there something I forgot to do?

 

See the other replies. I forgot to make the Keyword argument optional. Change it or download it again (same URL), as I’ve corrected that.

Link to comment
2 hours ago, vitor said:

 

Open Tick Tick. Open the Script Editor app, paste this code, run it (⌘R), and post the result.


tell application "System Events" to return (name of every process where background only is false)

You shouldn’t run stray code from the internet without understanding it, but that should be pretty clear. What it will do is return a list of every running app. It’s possible that `Tick Tick` is calling itself by a different name, and it should show there.

 

 

That’s the default and I forgot to change it. No argument is required.

 

My bad - the app in question is in fact TickTick (without a space), so changing the variable accordingly got it sorted.  Many thanks vitor.

Link to comment
6 hours ago, vitor said:

 

See the other replies. I forgot to make the Keyword argument optional. Change it or download it again (same URL), as I’ve corrected that.

Thanks a lot for your help. I wouldn't have recognized, that the answer was given in the other replies - due to my bad english.

I've downloaded it again and set 'firefox' as value. It works great. Thanks a lot again!

Link to comment
22 hours ago, vitor said:

 

See the other replies. I forgot to make the Keyword argument optional. Change it or download it again (same URL), as I’ve corrected that.

 

The plot thickens - how can I add multiple exceptions to this?  I tried adding another 'keep alive' variable (and adding a different app to it) but I'm guessing they have to be unique?

Link to comment
On 6/8/2019 at 2:30 PM, vitor said:

 

See the new version (same URL). It has instructions. It’s also untested.

Thanks viator. The newly version tries to close the second app listed - Fantastical 2. Below is the output from the earlier script editor text you provided, which seems to confirm the name of the app is Fantastical 2:

 

{"Google Chrome", "Finder", "Script Editor", "Fantastical 2"} 

 

I've also attached an image of how I've entered the apps to exclude from closing.

 

Any thoughts?

Webp.net-compress-image.jpg

Link to comment
On 6/27/2019 at 2:35 PM, vitor said:

Updated with a fix for the multi-app case. Also, it now uses commas to separate between apps.

 

There have been more people asking for this, so I’m likely to make it into a proper Workflow for sharing.

Thanks vitor, although Finder windows now don't close with that workflow - a necessary compromise, or something that could still be included?

Link to comment
On 6/27/2019 at 4:35 PM, vitor said:

Updated with a fix for the multi-app case. Also, it now uses commas to separate between apps.

 

There have been more people asking for this, so I’m likely to make it into a proper Workflow for sharing.

Hi Vitor,

 

Thanks for the workflow but it doesn't work for me, I couldn't figure out why. You can find the debug output below.

 

[11:59:33.073] Logging Started...

[12:01:55.375] Logging Stopped.

[12:02:25.236] Logging Started...

[12:04:34.766] Logging Stopped.

[12:04:35.493] Logging Started...

[12:04:46.458] Highlander App[Keyword] Processing complete

[12:04:46.462] Highlander App[Keyword] Passing output '' to Run Script

[12:04:46.877] ERROR: Highlander App[Run Script] /Users/Ceyhun/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/021C389F-7E69-4B77-B290-8E8E61904321:295:347: execution error: Error on line 7: Error: Application can't be found. (-2700)

Link to comment
2 hours ago, JJJJ said:

Error: Application can't be found.

 

That’s pretty self-explanatory. Whatever application you’ve set up to not quit, you’ve done so with the wrong name.

 

6 hours ago, bubbabr said:

Thanks vitor, although Finder windows now don't close with that workflow - a necessary compromise, or something that could still be included?

 

That could still be included. I’ll think about it for the official release. In the mean time, you can go into the Run Script and delete the line that reads keep_alive_array.push('Finder').

Link to comment
1 minute ago, vitor said:

 

How are you setting up the Workflow Environment Variable? Show me a screenshot.

 

What’s your macOS version? What’s your Alfred version?

Mojave 10.14.5.

Alfred 4.0.3

You can also find the debug output in the screenshot.1288972775_ScreenShot2019-06-30at22_23_39.thumb.jpg.6f2671e4809df69c9ca39c9c80aaa99c.jpg

Link to comment
1 minute ago, vitor said:

No idea. Might be something in your AppleScript setup, but this is only affecting you and might take a long time to debug. When I do the Open Office Hours, I’m open to have a look if you join, but for now I won’t pursue it unless someone else has the same issue and/or a clue.

Totally understandable, thank you for your interest. 

Link to comment
  • 2 weeks later...
  • vitor changed the title to [SOLVED] Quit all except [named app]

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...