Skip to content

Instantly share code, notes, and snippets.

@imekachi
Created May 30, 2022 15:01
Show Gist options
  • Save imekachi/c0c76f12f0abc3709d7162c7d3d6f2e3 to your computer and use it in GitHub Desktop.
Save imekachi/c0c76f12f0abc3709d7162c7d3d6f2e3 to your computer and use it in GitHub Desktop.
Switch magic trackpad to pair with another mac.
  1. install blueutil
    brew install blueutil
  2. Find your trackpad address by running
    blueutil --paired
    
    # address: 3c-a6-f6-b9-c6-c7, connected (master, 0 dBm), not favourite, paired, name: "Magic Trackpad", recent access date: 2022-05-30 2:41:17 PM +0000
    Replace - with :, you'll get 3c:a6:f6:b9:c6:c7
  3. Open Automator
  4. Create a new application
  5. Search for Run a shell script
  6. Drag to the right panel
  7. Enter following script
    res=$(/opt/homebrew/bin/blueutil --is-connected 3c:a6:f6:b9:c6:c7)
    
    if [[ "$res" = '1' ]]
      then
        /opt/homebrew/bin/blueutil --unpair 3c:a6:f6:b9:c6:c7
      else
        /opt/homebrew/bin/blueutil --unpair 3c:a6:f6:b9:c6:c7
        sleep 1
        /opt/homebrew/bin/blueutil --pair 3c:a6:f6:b9:c6:c7
        sleep 1
        /opt/homebrew/bin/blueutil --connect 3c:a6:f6:b9:c6:c7
    fi
  8. Save as Trackpad Pairing Toggle.app
  9. Move to /Application
  10. Copy this script to another device (don't forget to also install blueutil)

Now when you want to switch devices, you can use Spotlight or Alfred to search for "Trackpad Pairing Toggle" and just run the app on the connected device, it will disconnect from the current device. Then run the app on another device, it will connect to the trackpad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment