Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Script to swap your Bluetooth devices connections between two Macs. Works great with iMacMonitor.app to quickly switch your iMac between being a laptop monitor or full computer. http://bogner.sh/2013/07/os-x-how-to-use-an-imac-as-monitor/
#!/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
REMOTE=Stone.local
MODE=$1
case "$MODE" in
give)
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
;;
take)
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'"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment