Keep screen on while MacOS plays music

My MacBook is connected to a 4K screen with a single USB-C cable. This is great, since I can use the monitor as a hub, for things like USB devices and even audio.

The only time this is an issue is when I am listening to music in my office, but not actively using the computer, like if I am reading. That’s because I have configured by Mac to turn off an external monitor to save power. So after about 20 minutes of inactivity, my external monitor turns off, and I lose the audio.

I want to keep the “power display off after 20 minutes” feature, but I want to have a way to keep the audio active when I’m listening to music.

Macs seem to keep the screen alive in some cases, like if you’re watching a video with YouTube or Plex, but doesn’t do the same for Spotify. And the Spotify app doesn’t expose this as a feature.

(In fact, Spotify suggests changing the power settings. Umm, no thanks, I don’t want to waste electricity. I’d rather if your developers just fixed the app to call caffeinate whenever music is playing, that would be the best and simplest approach here. But given that Spotify has been asked about this feature 6 years ago, and they still haven’t added it, means that it’s unlikely they’ll ever have this functionality.

Apple Music seems to be impacted as well, so it’s not just third-party developers who can’t/won’t get this basic functionality working.)

After searching around a bit and asking ChatGPT about my options (link to that chat), I was about to start implementing a Golang CLI to do this work for me.

Then I stumbled onto Amphetamine! Amphetamine is an app that will prevent your computer from putting a monitor to sleep (among other features).

Amphetamine is pretty simple to use: just define the triggers that should keep the Mac awake.

At first I tried creating an audio trigger, but this didn’t work: my Mac stayed awake even if I wasn’t playing any audio.
(Not sure if this is a bug or not. It’s hard to find the home website for a given MacOS app, for some reason. And Google doesn’t help, just gives me a bunch of articles about Apple blocking Amphetamine. So I haven’t yet reported this to the developers.)

The trigger that ended up working is this one:


Simply put, this trigger is active when Spotify is the frontmost application. So now all I have to do is make Spotify active, and that is enough to keep my music playing indefinitely. A simple no-code solution. Though I do wish either Apple or Spotify would include this functionality in their products from the start.

Leave a Reply

Your email address will not be published. Required fields are marked *