C-Command Software Forum

Switching a Bluetooth Device to Another Mac

Here’s an idea for how to do this with one keypress. Say that you have Mac A and Mac B that are on the same local network (mac-a.local and mac-b.local) and you want them to share a keyboard (named Keyboard in ToothFairy):

  1. Go to System Preferences ‣ Sharing and enable Remote Apple Events.

  2. On Mac A, use ToothFairy’s Run shell script after connecting/disconnecting preference to set a disconnection script:

    #!/usr/bin/osascript
    tell application "ToothFairy" of machine "eppc://user:password@mac-b.local"
        set device "Keyboard"'s connected to true
    end tell
    

    You’ll need to fill in your username, password, and Bonjour name.

  3. On Mac B, set a disconnection script:

    #!/usr/bin/osascript
    tell application "ToothFairy" of machine "eppc://user:password@mac-a.local"
        set device "Keyboard"'s connected to true
    end tell
    

Now, whenever you disconnect the keyboard on one Mac, it will use AppleScript over the network to tell the other Mac to connect to it.

That’s very clever. I have a Trackpad that I would like to share with two Macs… I might give this a shot.