Auto Connect/Disconnect Bluetooth Mouse and Keyboard in shared office space

Hi There,
I would like to set the following up somehow.

My family uses a mac mini at home. Every once in a while I use the desk to work from home, at least once a week. I like to use the large monitor, so plug it into my Macbook Air. Then I disconnect the bluetooth apple keyboard and magic mouse from the mac mini and pair them with my Macbook Air. Once I am done working I want everything to be back the way it was, so I disconnect the mouse and keyboard from my Air and (via Screen Sharing) reconnect both to the mac mini.

The goal is to either press one keyboard shortcut or have it work fully automagical. Trigger could be connecting and disconnecting from the specific monitor at home.

I have set up 4 macros, one on each mac to connect and disconnect the mouse and the keyboard. (each computer has a dedicated macro group for macros that should only run on that computer) So, on the mac mini, I have a 'disconnect' macro that runs an apple script (I lifted it here (1) - a similar question on this forum is (2) but nothing more was offered in terms of information). After the apple script does its thing it triggers the 'connect macro' in the Macbook Air macro group. The same would work vice versa, either with a keyboard shortcut or when disconnecting the monitor.

I got it to connect, but I don't know how to disconnect the bluetooth devices via apple script or other means. Any ideas?

Global Home Server Macros.kmmacros (4.7 KB)
Macbook Air Macros.kmmacros (5.9 KB)

(1) from
(2) How can I connect my MacBook to a bluetooth speaker using KM?