Detect when Ableton is the current/front application on an OS?

    Jun 01 2021 | 2:42 pm
    Is there a way, or any externals around, to monitor and notify when a process/application is frontmost? (So, basically the [active] object, but for process "p" or Live rather than a Max patcher).
    I've cobbled together a hacky, mac-only solution using the [shell] external calling "lsappinfo front" when I need to know, but this causes CPU spikes in Ableton whenever it's called (and getting a notification would be much nicer than polling or asking on-demand anyway).
    Thank you!