logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·30.10.26
← Back to news

Magic Switch: Share Apple Magic keyboard/track-pad/mouse between two Macs

Original article
joshua.hu|57 points|25 comments|by chanux|Oct 2, 2026

Magic Switch: Seamlessly Share Apple Peripherals Between Two Macs

TL;DR: Magic Switch is a complimentary, open-source macOS utility designed to let you share an Apple Magic Keyboard, Mouse, or Trackpad across two different Macs. It eliminates the need for a shared Apple ID and removes the tedious "USB re-pairing dance."


🌏 A Journey Home and a Change of Perspective

I recently made my way back to Poland after spending approximately 777 months living in Taiwan. My time there was an adventure filled with bike riding, studying Chinese, and gaining life experiences I never anticipated.

Upon returning, I realized I could no longer view myself as a mere tourist; it was time to actually invest in my (rental) apartment to make it feel like a home. While I have a deep passion for interior design, for the last five years, I've been strictly utilitarian—investing only in absolute essentials despite the low cost of living. I am a minimalist at heart; I've spent months living entirely out of a backpack.

Interestingly, my guests via Couchsurfing always praised my eye for design and the way I oriented my space. However, Taiwan changed me. Moving every week or two and visiting countless galleries, museums, and studios left a mark. I've finally succumbed to the desire for life's conveniences—perhaps I'm simply getting older.

I've put immense effort into coordinating colors, materials, and sourcing rare design pieces. The thought of being evicted is now devastating, as these specific choices (tiles, palettes, curtains)\text{(tiles, palettes, curtains)}(tiles, palettes, curtains) likely wouldn't translate to a different apartment.

⚡ The Physical Struggle

My working habits are unconventional. I typically work from bed or while reclining. For me, sitting at a desk has always been an agonizing experience. After roughly five minutes of sitting, my back suffers from spasms of an intensity unlike any other pain I've known.

I suspect I have Ehlers Danlos Syndrome, which explains my extreme flexibility but also my chronic back issues—problems that neither surgeons, doctors, nor well-meaning friends could resolve. To describe the sensation, I look to George Orwell’s 1984:

"[..] his body was being wrenched out of shape, the joints were being slowly torn apart [..]"

Consequently, I invested in a standing desk.

⌨️ The Peripheral Problem

Along with the desk, I acquired a monitor, which necessitated a keyboard. I went with the "free" route: an Apple Magic Keyboard and Magic Trackpad.

These are Bluetooth devices that require an initial USB-C handshake for pairing. However, Apple's philosophy of "it just works" has a glaring flaw: these peripherals cannot be connected to multiple devices simultaneously.

Comparison: AirPods vs. Magic Peripherals

FeatureAirPodsMagic Keyboard/Trackpad
Multi-device PairingYes (Seamless switching)No
Switching MethodAutomatic/MenuPhysical USB Re-pair
Apple ID Required?For seamless syncFor "Universal Control"

If you try to switch devices, you can't simply disconnect from one and pair with another. Even if both are paired, the peripheral simply Won't Work™ unless you perform a full re-pair via USB.

While Apple offers a solution via Settings →\rightarrow→ Display →\rightarrow→ Advanced →\rightarrow→ Link to Mac or iPad, this requires both machines to share the same Apple Account. This is a dealbreaker for me, as I often cannot or do not wish to log into my Apple ID.

Blue-Switch UI Placeholder

🛠️ The Technical Evolution: From blue-switch to Magic Switch

I discovered an open-source project called blue-switch. It provided a basic menu bar interface to disconnect a peripheral from one Mac and force it onto another.

How it Worked (The Logic)

The app used a "hack" to automate the re-pairing process via the network:

  1. Discovery: Two Macs find each other using mDNS (Bonjour).
  2. Communication: They establish a plaintext TCP channel.
  3. Command: One Mac sends a request to the other to drop the connection.
  4. Execution: The receiving Mac forces the peripheral to connect to itself.

The Limitations of blue-switch

Despite the brilliance of the concept, blue-switch was merely a proof-of-concept:

  • Security: It trusted every device on the local network.
  • UX: The user interface was virtually non-existent.
  • Stability: It lacked any meaningful error handling.

The Underlying Architecture

As analyzed by Claude, the original app's workflow followed this sequence:

  1. Discovery: mDNS/Bonjour→Exchange Host + Port\text{mDNS/Bonjour} \rightarrow \text{Exchange Host + Port}mDNS/Bonjour→Exchange Host + Port.
  2. Control Channel: An NWConnection was opened to send specific string commands:
    • CONNECT_ALL
    • UNREGISTER_ALL
    • NOTIFICATION
    • SYNC_PERIPHERALS
    • HEALTH_CHECK
    • OP_SUCCESS / OP_FAILED (Acknowledgements)
  3. The Bluetooth Trick: Upon receiving CONNECT_ALL, the Mac utilized IOBluetooth to force the pairing.
// Conceptual logic of the force-pair command
if command == "CONNECT_ALL" {
    BluetoothManager.forcePair(peripherals: targetList)
    sendAck("OP_SUCCESS")
}