Interstellar Boats

Stop the Music.app

Posted on

Apple does not provide an option to rebind , also known as the Play/Pause button. By default it opens Music.app when nothing is playing, whereas I would prefer that it open Spotify and resume playback1.

noTunes exists as a dedicated app to solve this problem. Unfortunately it did not work for me. It did block Music.app from opening but there was an issue around launching and starting Spotify.

It is probably possible for noTunes to perform perfectly, however I searched on for a more general solution instead. (Music.app is not the only default app I would rather not use) If this or another solution2 works for you: Great!. Operating correctly, it almost certainly would be a smoother experience.

The Fix

The forage for a finer fix followed another flow, and for a patchwork solution the final result functions fairly well. It pairs Apple's Shortcuts, which handles the applications, with Shortery as a trigger, and is completed by running a small AppleScript to start the music.

First we need the shortcut.

It will:

  1. Launch and Focus Spotify
  2. Run the few lines of AppleScript which send a Space Bar key press to Spotify
  3. Hide and Quit Music.app

This may look a bit out of order, but the time it takes for Music.app to launch is better spent starting Spotify and beginning playback. Cleanup can occur hidden in the background.

Second step is to setup Shortery.

Screenshot of Shortery as it should configured to run on launch of an application

Here ⊕ Add Shortcut Trigger and select:
  1. Application as the trigger type
  2. Our No Music shortcut.
  3. Music.app as the Application

This only runs when the music app launches, keeping our shortcut simple and allowing all other default behavior of can remain.

Note:

  • You will need to Allow Running Scripts in Shortcuts under Settings... > Advanced

  • You will also need to click accept on a few automation and accessibility access alerts, needed to send the key press, and watch for application launches.

Other Instances of Music.app

The above automation solves the primary keyboard issue at hand, however it still launches as the default player for any audio files. This will be annoying as with this shortcut setup the music app will quit every time it opens.

Luckily Apple has allowed the ability to adjust this to another app.

The obvious flow in finder (Open with > Other... > VLC) does not provide the option to change the default for all files of that type. This only opens that specific file in VLC, however as described here the less obvious flow can be used:

Right Click > Get Info > Open With: VLC > Change All...

This must be done for each file type but eventually we will run out of new file types to update, and this will not be an issue.


The Notes.app

I wrote this post in Obsidian; which is where I handle all of my notes. I do not use the included Notes.app, but do like the Hot Corner Shortcut that exists for it. It would be more useful if it could launch Obsidian. Unfortunately that shortcut is limited to only a few actions.

Screenshot of the (rather limited) Hot Corner Shortcut options

Notes.app will launch from the Quick Note action so we can follow a familiar pattern and fix that right up. Swapping to sending Ctrl + n could finalize this shortcut for a quick note, but Obsidian has options and plugins for daily notes so this all will be left left as an exercise for the reader.3


1

Yes! A footnote for the first paragraph! Generally I end up clicking under the assumption Spotify is already open since in my it lives in desktop view to the right, so I am expecting playback to begin.

2

Options such as Karabiner Elements and Keyboard Maestro also exist and may provide a solution to modifying this operation closer to the keyboard level, but have not been thoroughly explored, and are left as an exercise to the reader.

3

Spotify and Obsidian are used in this write up, however the shortcut should accommodate swapping to whichever apps you like, as well the AppleScript swapping the keys pressed, with more details here on that front.