The Case of Missing macOS Sleep Trigger
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.