Create a gist now

Instantly share code, notes, and snippets.

Script to swap your Bluetooth devices connections between two Macs. Works great with to quickly switch your iMac between being a laptop monitor or full computer.
#!/usr/bin/env bash
# This script works after you've paired the Bluetooth devices with
# both the local and remote computer. Turning one off and the other on
# forces the devices to reconnect with the only computer that has BT on.
# Look up local SSH hosts with Bonjour using `dns-sd -B _ssh`
# You may want to set up an SSH keypair to log in without typing a password
case "$MODE" in
echo "Give it away now..."
# Power up remote so they attach there
ssh $REMOTE 'blueutil power 1'
# Release devices from local Bluetooth
blueutil power 0
echo "Bring it back..."
# Power up local to receive them
blueutil power 1
# Release devices from remote
ssh $REMOTE 'blueutil power 0'
echo "specify 'give' or 'take'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment