The Case of Missing macOS Sleep Trigger

I was on a lookout for a certain trigger to automate macOS, a sleep trigger. I try not to automate any of the scripts around uncertain triggers, especially sleep cycles, when there may be certain expectations of how things should be at that moment. For example, if a script inadvertently disrupts the machine from going into sleep, as a user, it would be confusing why the machine simply fails to go into sleep. Not to mention if I ever forget such a script is running in the background, it would be pain to discover it again. But when I actively needed one for my project, I couldn’t find one so easily.

There were some tools I’ve found; a lot of them were unmaintained. Looking at some of the old blog posts from the developers, it is inherently a flawed idea. Once the system fires the sleep trigger, there is no way of knowing how much time is left to execute any code, let alone load one. I think it’s a fair point. It would be odder if it did announce loudly before going into sleep.

The reason why I wanted such a trigger in the first place was to quit Apple Music before putting the Mac into sleep. With Apple Music individual plan, you can stream music up to one device, and it is absolutely strict about that one device policy. Whenever I stop playing music from my Mac and shift to my iPhone, the Music app on macOS creates multiple popups warning me my subscription only supports one device if the app is left on. It’s bizarre there is no way of muting the popups entirely; I am aware of the limitations of the tier, no need to remind me again. The fact that the app won’t stop spamming even when it’s not playing is just the cherry on the top.

My band-aid solution, currently, is to map my keyboard so that it would quit Music app before putting the computer into sleep. It can be done on pretty much any keyboard related softwares, even on bundled Logi Options+. Obviously, this is not a complete replacement of the actual sleep trigger. Or we could dream for the day when Apple finally decides “individual” means one person, or fix however its app is firing up all the warnings.

Leave a comment