Trigger custom script on specific log message I am using AirServer for Airplay on my Mac. As far as I know, AirServer does not provide an interface to run scripts on specific actions. However, I found a AirServer specific message inside the Console app whenever a device connects or disconnects to the service. I also tried the following in Terminal:

log stream | grep "AirServer"


I am looking for an efficient way to run a custom script whenever the process AirServer spills out a specific message (in my case connect/disconnect).
AirServer implements a basic AppleScript interface which can tell you if AirServer is in use by calling:
osascript -e "tell application \"AirServer\" to inUse"

Another approach is create a basic app which monitors AirServer's notifications using NSDistributedNotificationCenter:
com.airserverapp.MirroringDidStart, com.airserverapp.MirroringDidStop,
com.airserverapp.AudioDidStart, com.airserverapp.AudioDidStop,
com.airserverapp.VideoDidStart, com.airserverapp.VideoDidStop