Automation for Keyboard & Mouse Switching

Hello,

Looking for some help around a problem I am having. I recently had to purchase a personal MacBook Air because of restrictions on my work MacBook Pro. This is the first time I will be using two computers let alone two laptops. My setup is two laptops mentioned above, a Studio Display, an Apple Magic Keyboard and Apple Magic Mouse. I am wondering if there is some automation or Alfred workflow that I can trigger when I unplug the Studio Display from one laptop to another both the keyboard and mouse switch as well? Addition, both laptops are in clamshell mode so I can’t really use the keyboard.

I would prefer not to spend more money on a switch, just looking for some automation or workflow.

Thanks in advance

Barriers (free) or ShareMouse (Pay)?

2 Likes

I have almost this exact setup (a locked-down work MBP and a personal Mac sharing a Studio Display) and ran into the same annoyance since Universal Control is a non-starter across two different Apple IDs.

A couple of ways to handle it depending on how you work:

  1. For the Magic Keyboard (hardware trick, zero software):
    If you leave a short USB-C cable plugged into one of the three USB-C ports on the back of the Studio Display and plug the other end into your Magic Keyboard, macOS automatically re-pairs the keyboard’s Bluetooth to whichever MacBook gets the Studio Display Thunderbolt cable. Even if you unplug the keyboard later, it stays paired to the active Mac.

  2. For the Magic Mouse in clamshell mode:
    Since Apple put the charging port on the bottom of the Magic Mouse, you obviously can’t leave it wired to the monitor while using it.

  • If you want an Alfred workflow you trigger right before swapping the Studio Display cable: install blueutil (brew install blueutil) on both Macs. Create an Alfred trigger that runs blueutil --unpair <magic-mouse-mac-address> on the Mac you’re leaving, and have a small background launch agent or Shortcut on the other Mac that runs blueutil --connect <mac-address> when the Studio Display wakes it up.
  • If you keep both laptops awake on the same local Wi-Fi: ShareMouse (which @NiKoBeaR mentioned) or MultiMac both work over your local network without needing the same iCloud/Apple ID. I ended up using MultiMac for Mac-to-Mac cursor and clipboard handoff when both machines are running, and the blueutil + Studio Display USB-C trick when one laptop is asleep in my bag.