In the office alone last week, running processing macros on the iMac while working on hardware on the bench next door, I needed an alert that would be:
- Attention grabbing
- LOUD!
- Continuous, so I wouldn't miss it if called away to a user for 10 minutes
- Cancelable once I got to it
Attention grabbing is easy -- what better than the Star Trek TOS red alert? If it's good enough for Kirk it's good enough for me! Download, and move it into ~/Library/Sounds if you want to make it available to the OS as well.
There's loads more sound files at TrekCore.com if you want to get your Trek on in other ways.
Loud -- we just need to whack up the volume, unmuting if necessary, remembering to reset afterwards.
Continuous means we're going to need a loop, and that means an async sub-macro so it isn't blocked by the "Alert!" Action. That also makes it cancelable by killing the sub-macro.
Bonus: There's a good chance I'll be playing tunes through Music -- if so I need to stop the song before the alert and resume playing after.
Extra bonus: Using the "native" KM Action for the sound playing means that if anything goes wrong you can cancel that macro to stop the noise -- much easier than looking for afplayer process IDs to kill!
The alarm's simple enough -- log the instance UUID (if you don't like using Global variables you could search all executing instances for a macro name match) then run an infinite loop that plays the sound:
Alarm!.kmmacros (2.3 KB)
The calling macro is a bit more involved, mainly because of the current-state getting and setting. The fun bits are calling the "Alarm!" macro asynchronously before spawning the alert, and putting the "Alert" Action in a "Try/Catch" block so that you can do the state reset regardless of which button was pressed. You can then branch dependent on the %AlertButton% Token.
Alert Demo.kmmacros (12.7 KB)
This saved my bacon half a dozen times last week -- and totally freaked out a Fire Warden when it went off during a fire drill! Hopefully it, or some of the ideas within, will be useful to others -- even if only the Trek sound archive ![]()

