A preset to toggle (quit or launch) an app when a display is connected or disconnected
Displays Changed --> Toggle App (Launch or Quit).bttpresetzip (27.8 KB)
This BTT preset quits or launches an app of your choice (with dialog confiramtion) when an external display connects or disconnects.
I'm finding this useful since I'd prefer not to have my menubar manager (Barbee, Ice, Bartender, etc.) running when I'm using an external display, and I want to be reminded to enable it again when I to only my macbook display.
Setting up:
- Open the trigger folder under "Automations, Named, and Other Triggers"
- Select the trigger "Settings: app name and quit/launch preference"
- In the first Set Value action, enter the name of your chosen app in the Value field:
- In the second Set Value action, enter either "quit" or "launch" (without quotes) in the Value field.
This is what the preset will do when a display is connected. (And when a display is disconnected, it will do the opposite option).
- Click "Save".
The chosen app is never quit or launched automatically. First a dialog pops up, where you can confirm or cancel the action.
The preset also does its best to clear any lingering dialogs of its own that have been previously ignored, and it includes triggers for BTT startup, and for before and after Mac sleep, macbook lid closing, and screensaver.
Note: This app uses the shell command kill to quit the chosen app immediately after approval. This is a workaround for an issue where some menubar apps (Barbee) refuse to quit when asked politely. Killing an app's process is generally not a problem for most apps, but if you're using this preset on an app that has unsaved content, for example, killing its process will result in the content being lost.
Release Notes:
- 2025-11-01:
- add triggers for macbook lid close/open, screensaver stop/start, and BTT startup
- add logic to prevent two instances of the script from running simultaneously
- minor code reformat
- 2025-10-28:
- reformat javascript (JXA)
- 2025-07-23:
- fix some apps (Barbee.app) refusing to quit
- fix variable scope
- 2025-07-16:
- fix not being able to interact with menubar item of some launched apps
- 2025-05-12:
- refactor javascript
- store javascript as preset file
- rename preset without
/in title
- 2025-05-12
- initial release

