Quit idle application macro - is it possible to make this macro generic

So, I created a Quit Idle application macro based on ideas on this forum. Attached below.

As of now, that macro works for one application. I would like to, ideally create a list of application names, and have the macro run through that list. Is it possible to do that?

Or is this in "create a script" territory?

Thank you.


Quit idle applications.kmmacros (5.9 KB)

Yes, it is possible.
Just create a list of current apps (using a script), and cycle through each one.

However, may I ask what you are trying to achieve?

Triggering a macro every minute, then cycling through all open apps is likely to consume as much, if not more, resources that just leaving your apps open.

IME, most well-behaved apps consume very little resources when not active. There are exceptions, of course.

Overtime, a lot of applications are launched and start crowding the application switcher area (for example right now there are 20 apps in KM switcher screen).
And these apps likely also use some computer resources and precious battery.
Apps such as Apple Notes, Messages, iTunes and a bunch of others.

Ideally, I would like to quit these apps if they have not been used for 10-20 minutes. Of course, this every minute macro may be the wrong approach.

Does it make sense? Do you actively quit applications after switching away from them?

Thanks for your reply!

Thought some more and wondering if this may be less CPU intensive from a KM macro perspective. This also feels such that I can enter a list of applications and make it work. Do comment.

You may want to look into the free app Quitter. It allows you to specify inactivity times after which each app will automatically quit.


Thanks @NaOH. Looks good and this may be what I should adopt! Just that it will be yet another application running and constantly polling my system. There are so many :smile:

Since, KM is already running all the time, I wonder if I can use the last_application_active_time and run a macro every 10 minutes or so and if current time is more than 10 minutes after last_application_active_time, to quit the apps of interest.

I tried something but date math in KM is not simple. I guess I will get to it in some time, and will try to use "quitter" until then.

Thank you.

Well, each of us has developed a style that works for us. Here's my method, which may, or may not, work for you:

  1. On Mac startup, I have a KM Macro that launches my core apps. There are about 6 of these, and they pretty much stay open all day long, as I often use them.
  2. All other apps, I open, use, and close, as needed. I keep the app open until I don't have any further anticipated use during that day.
    • I do this with even some of my most important tools, like Script Debugger 7.
    • As a result, I may open apps like SD7 2 or 3 times a day, but it's no big deal because of the next item.
  3. I mostly use LaunchBar to launch and switch between apps, although I do use the Mac App Switcher some.

This keeps my App space uncluttered, and takes very little effort. On my iMac-27 Late 2015 model, launching most apps is very fast, even the Microsoft Office apps.



Those are some great ideas. Makes sense to have a a KM Macro launch core apps.
And even though I have used Launchbar for many years, I did not know about their app switcher. Looks quite good and I will opt for that from now on. Ability to select application by name after invoking Launchbar switcher is also great.

And for now I have downloaded the Quitter app by Marco Arment.

Thank you for sharing your workflow!

The LaunchBar’s built-in application switcher does work well, but, to be clear, what I was referring to is simply using the LB abbreviation I have assigned to my favorite apps. So I do the same thing to launch as to switch to an app: Activate LB and type the app code.

Most of my LB app codes are 1-2 char, like:

  • F - Finder
  • PF - Path Finder
  • SD - Script Debugger
  • KM - Keyboard Maestro
  • etc

These are now all muscle memory, so I find it much faster to use than either the LB or macOS app switcher.

But that's the great thing with all of these tools -- so many different ways to use, so each of us can choose what works best for him/herself.

I agree. I do use Launchbar to launch apps and should rely on it more when switching also.

Using Switcher shortcut is faster for the last app used.

So that is what I will do now. LB for most switching, and cmt-tab for last app.


1 Like