Skip to content

How to run script when a monitor is connected/disconnected? #3568

Answered by waydabber
dangh asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, I see. Well, you can check if a display is connected or disconnected via BetterDisplay's CLI but there is no way currently to trigger a script based on events. There are some tools like HammerSpoon that have something like that or you can simply create a very simple solution with some coding of your own that looks out for the changes by looking for the right system notification dispatch and check the nature of the change.

For more info:
https://developer.apple.com/documentation/coregraphics/1455336-cgdisplayregisterreconfiguration

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@dangh
Comment options

@waydabber
Comment options

Answer selected by dangh
@waydabber
Comment options

@dangh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants