BetterDisplay icon indicating copy to clipboard operation
BetterDisplay copied to clipboard

Trigger a shell script, URL call or send message when a specific is connected/disconnected

Open quocpeyrot opened this issue 1 year ago • 8 comments

Hello,

now that issue #3682 has been implemented, it would be awesome to be able to trigger a script as well, one for connected and one for disconnected. That way we could easily switch some settings automatically (dock position, mouse scrolling direction etc.).

I know we could use 3rd party software for that, but since you already implemented the detection, it shouldn't be too hard to implement a trigger.

Thx for your awesome software btw, I'm an happy pro version user.

quocpeyrot avatar Jan 11 '25 18:01 quocpeyrot

Yes, I plan something like this (ability to run scripts on various events).

waydabber avatar Jan 11 '25 18:01 waydabber

Do you have an approximate ETA for it?

quocpeyrot avatar Jan 13 '25 09:01 quocpeyrot

I generally don't have ETAs for features. :) But you can easily write a simple solution in Swift or use Hammerspoon or some other scripting tool that already watches the appropriate events until this is implemented.

waydabber avatar Jan 13 '25 09:01 waydabber

Upvoting for this feature :)

Shortcut would also be nice, as it can run any other things like AppleScript, bash scripts or custom action.

Would love to disable all virtual displays when connecting main screen etc.

dmkpoznan avatar Feb 12 '25 10:02 dmkpoznan

I generally don't have ETAs for features. :) But you can easily write a simple solution in Swift or use Hammerspoon or some other scripting tool that already watches the appropriate events until this is implemented.

Hey! Would you happen to know which event I should be listening to for when my display connects/disconnects?

aviwad avatar Apr 01 '25 17:04 aviwad

Hammerspoon has I think a specific solution. In Swift you should use this and then evaluate the returned flags to determine the nature of the configuration change.

CGDisplayRegisterReconfigurationCallback({ displayID, flags, _ in myConfigFunction(callback: true, displayID: displayID, flags: flags) }, nil)

waydabber avatar Apr 01 '25 17:04 waydabber

But I will probably add this feature soon now as it fits my current work on control integration nicely.

waydabber avatar Apr 01 '25 17:04 waydabber

Hmm. I started implementing this but then came to the conclusion that to do this the right way I will need to create some general mechanisms for all other kinds of event driven integration scenarios so the feature-set can be expanded on the future. So I think I will do this in an other update instead as this will be a more complex project, don't want to do something hastily now that doesn't fit well. Sorry about that.

waydabber avatar Apr 04 '25 16:04 waydabber