The Problem

I was just thinking about my signal-to-noise ratio during coding and I noticed that my OS X dock has lots of stuff in it. I like this stuff. I want to keep this stuff. Also I hate a dock that hides. But I thought this: it would be nice to have an icon to click on that switches the dock between “only show running apps”-mode and normal mode.

It turns out that this is easy because some awesome apple employee hid this function in the dock. I just need a little script that toggles the state and restarts the dock. Here’s that little script:

""" Toggles static-only, then restarts the dock """
import subprocess
def dock_is_focused():
    """ Return true if the dock is in static-only mode """
        mode = subprocess.check_output(
            "defaults read static-only".split(),
    except subprocess.CalledProcessError, exception:
        if exception.returncode == 1 and "does not exist" in exception.output:
            return False
    if "1" in mode or "t" in mode or "T" in mode:
        return True
    return False
def focus_dock():
    """ Sets static-only to true """
        "defaults write static-only -bool true".split())
def unfocus_dock():
    """ Sets static-only to false """
        "defaults delete static-only".split())
def restart_dock():
    """ Runs osascript to restart the Dock the applescript way """
                           "-e", 'tell application "Dock"',
                           "-e", "quit",
                           "-e", "end tell"])
if __name__ == "__main__":
    if dock_is_focused():

The final part of the solution is an app to click on. I whipped out the ever-useful always-underrated Platypus, fed it, “made” a crappy icon1, and voilà! Icon

DockFocus.dmg (click the icon to download)

  • Contains
  • The License is BSD-like
  • This software come with no warranty at all

Unnecessary User Manual

Installing It

  • Download and open the above DMG
  • Copy the app from the DMG to your applications folder or your desktop
  • The app isn’t signed, so if you have GateKeeper turned on (as you should), you will want to right-click the app the first time and select “Open”, then click the “Open” button. (from then on it will work normally – if you have trouble with this, check out that GateKeeper link)

Using It

  • Every time you run the app it will switch the dock between “focused” where only running apps are showing and “unfocused” where all apps show

Uninstalling It

  • To uninstall the app just drag it to the trash
  • If you deleted the app while your dock was “focused” then you can just download it again, and run it one more time. If you don’t want to do that, you can also copy-and-paste this directly into the terminal to get things back to normal: defaults delete static-only

  1. icon mostly “inspired by” by Apple’s dock icon [return]