The truth is that this cannot be done officially on the Mac, so I had no choice but to find a workaround to do it. Whenever I press play to start playing music and the app is closed—which happens often—Apple Music opens by default, and damn it, I don’t use it at all. In my case, I use YouTube Music, so the script I created is designed to run this application, but if you use another one, it works just the same, because you can even use it to open the notes editor if you feel like it.
In the video, I walk you through the steps to do it, but here are the commands I use, along with the contents of the .plist file and the AppleScript.
Zsh
touch ~/Library/LaunchAgents/com.ektorcaba.watchmusic.plistZshRemember to replace “ektorcaba” with your Mac’s username.
com.ektorcaba.watchytmusic.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ektorcaba.watchytmusic</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>/Users/ektorcaba/Documents/cerrar_music_abre_youtube_music.scpt</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/ektorcaba/Library/Caches/com.apple.Music</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/music_watch_stdout.log</string>
<key>StandardErrorPath</key>
<string>/tmp/music_watch_stderr.log</string>
</dict>
</plist>XMLcerrar_music_abre_youtube_music.scpt
tell application "Music"
quit
end tell
tell application "System Events"
if exists (process "Music") then
do shell script "killall Music"
end if
end tell
tell application "Youtube Music" to activate
AppleScript
