08/27/13 16:35:25

3 More Ways to Deal With Distractions Using Keyboard Maestro

3 More Ways to Deal With Distractions Using Keyboard Maestro

I wrote about a way of taking a serious break using Keyboard Maestro before. It’s not that I really need this anymore, but by the time it was really important for me to work on rituals.

The following workflows are going along similar lines, though they are more geared for the workspace. The goal here is to quit certain apps when they have been launched accidentally during work time. I thought the following might be helpful to hear so that other folks can use some of this in their own distraction free approach.1

I find checking every ten minutes a good measure, because even though I launched these apps, why should they quit immediately? Why would I want to hurt myself that badly? When I check Facebook for a minute or two I think that’s acceptable. It is better to get an occasional reminder not to do so, every once in a while.

If App Is Running, Quit It

The simplest one is a macro in the form of “if an app is running, then quit it”. These macros look like this:

Note that you can use multiple “While Logged In” conditions to allow breaks.

If App Is Non-Cocoa App or Non-GUI App, Quit It

The second class of “apps” are a bit trickier. These don’t show up as “running” applications in Keyboard Maestro’s If Then Else action (“if this application name is running”. Compare with screenshot above). Typically these are non-GUI apps such as processes or, in my case, Minecraft or Feed the Beast. Luckily we can use Keyboard Maestro to only run if a secript returns success. Some ps and grep trickery helps to filter out ps/grep.2

ps aux | grep "[F]TB_Launcher

If App Is Web App, Quit It

The third kind of app category is a little harder to quit, but not impossible either. Facebook is an app that I only use in Safari. Luckily we can use some AppleScript magic to close tabs directly. This script work with Google Chrome, too. Just change to tell application "Google Chrome":


  1. Good luck! 

  2. You can use this on a server to monitor whether your http server is up and running, e.g. ps aux | grep "[n]ginx”