A Workaround for Broken Media Keys in High Sierra milgra.com

In previous versions of MacOS, media keys would control whatever audio- or video-specific app was most recently foregrounded. If you launched iTunes, say, and then played some songs in the background, they would control iTunes; if you switched to Spotify and then put that in the background, the keys would automatically control Spotify instead. The keys would also work with QuickTime, VLC, and other media apps, but they never controlled playback in web apps like Netflix or YouTube, and that probably irritated some people very much.

In High Sierra, Apple has resolved this — web apps that play media now get the same priority as native apps. And that’s fine and well.

The problem is that there’s a bug where media keys simply stop working altogether. I’ve seen all sorts of tips: quitting Chrome might help, quitting Slack might help because it’s effectively a Chrome browser, quitting Safari might help, and making sure no tabs are open with embedded media. But these tips are ridiculous, and if iTunes or Spotify are presently playing audio when I press a key, it’s a no-brainer what I’m trying to control. I’ve dumped the Console output on Pastebin for those who are curious.

Anyway, I got fed up with this tonight so I started poking around for a solution and stumbled across a tiny menu bar utility by Milan Toth. It doesn’t support the Touch Bar and it seems to only work for iTunes and Spotify, but this is pretty much perfect for my needs.

One small worry is that it is unsigned, so High Sierra throws a hissy fit if you try to run it. Toth has open-sourced the app so if you’re worried about it, you can review the code. You can also easily compile and sign it yourself, which is what I did for my copy. I’m thrilled that my media keys now behave as I expect them to, but I’m once again dismayed that there’s yet another problem with an input mechanism for MacOS.