Keyboard Maestro beats System Preferences

Way back in September of 2014, I wrote about a problem I was having with a keyboard shortcut to toggle Mission Control’s Show Desktop feature. Basically, whenever I rebooted my iMac, the keyboard shortcut stopped working, even though it was still checked in the Keyboard Shortcut system preference.

Keyboard Shortcuts

I found a workaround:

Through trial and error, I’ve learned how to solve the problem and, in some cases, how to prevent it from happening in the first place. If I uncheck the Show Desktop box in the Keyboard Shortcuts panel and then reboot, rechecking the box after the reboot will get the shortcut working again. Unfortunately, I reboot so infrequently that I almost never remember to uncheck the box ahead of time. It’s only after I get a beep when I hit F6 that I realize what I’ve done have to reboot a second time.

This problem started with Mavericks and occurred only on the iMac, never on my MacBook Air. Rereading that post, I see how innocent and naive I was back then:

With luck, Yosemite will erase this annoyance and I won’t have to think about it again.

As you have no doubt guessed by now, Yosemite didn’t erase the annoyance. Nor did El Capitan or Sierra. Today, after running into the problem once again, I decided to take matters into my own hands. I turned off that shortcut in System Preferences and built a Keyboard Maestro macro to do the job.

It’s a one-step macro:

Show Desktop macro

The macro is triggered by F5, the only function key on both my iMac and MacBook Air that doesn’t have a feature assigned to and printed on it.

MacBook Air function keys

The shell command it executes is

/Applications/Mission\ Control.app/Contents/MacOS/Mission\ Control 1

which I learned about indirectly through this old Mac OS X Hint. Back when the hint was written, there was no Mission Control, but there was Exposé, and the hint is about calling the Expose binary buried in the Expose.app package:

/Applications/Utilities/Expose.app/Contents/MacOS/Expose 1

After reading the hint, I guessed that the same thing would work with Mission Control. And it did. Once I knew the invocation, I was able to search for it directly and found this Ask Different page, which explains the arguments you can pass to it:

The other two behaviors don’t interest me, as I’ve never had a problem with the keyboard shortcuts for Mission Control or Application Windows. And now I won’t have a problem with Show Desktop, either.