Skip to content

Instantly share code, notes, and snippets.

@turadg
Forked from hughsaunders/release_bt_keyboard.sh
Last active December 22, 2015 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turadg/6530344 to your computer and use it in GitHub Desktop.
Save turadg/6530344 to your computer and use it in GitHub Desktop.
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