The only game I play on the Mac Mini connected to our TV is Cuphead.
I wanted the game to launch automatically when I turn on one of our Nimbus game controllers, which connect via Bluetooth.
This is how:
- Save the .scpt file below as e.g. ~/Library/Scripts/LaunchCupheadIfControllerIsConnected.scpt
- In the .scpt, change "Nimbus" if your Bluetooth game controllers have some other name.
- Save the .plist below as e.g. ~/Library/LaunchAgents/henrik.launch_cuphead_if_controller_is_connected.plist
- In the .plist, change
media
to whatever your username is.
- In the .plist, change
- Load the .plist as a launch agent with
launchctl load ~/Library/LaunchAgents/henrik.launch_cuphead_if_controller_is_connected.plist
That should be it. When something changes about Bluetooth devices, the launch agent will trigger the script. The script checks if there is a connected device with "Nimbus" in its name (our controllers are named "Nimbus 1" and "Nimbus 2"). If so, it launches Cuphead if not already launched.
On the first run (possibly two runs?) you should get a macOS prompt to confirm permissions.
Works for me(tm) on macOS Mojave.
I'm, *checks date*, 3 years late. But I'm also trying to set up something else to listen to
com.apple.Bluetooth.plist
and am also finding that it never triggers. I'm running macOS 14.6.1@andreabusi / @henrik Were either of you able to get the listening part working?