Skip to content

Instantly share code, notes, and snippets.

@breiter
Last active July 7, 2022 17:56
Show Gist options
  • Save breiter/9f8aeeb438d9eb6c93aac32988414b9e to your computer and use it in GitHub Desktop.
Save breiter/9f8aeeb438d9eb6c93aac32988414b9e to your computer and use it in GitHub Desktop.
Restart bluetoothd in macOS
#!/bin/sh
#kill bluetoothd to reset bluetooth wonkiness in macOS
#catalina, big sur, monterey
#fixes continuity, magic keyboard mismapping of function keys, magic mouse scrolling
current_userid=$(id -u)
if [ $current_userid -ne 0 ]; then
echo "$(basename "$0") requires superuser privileges to run" >&2
echo "try: \033[1;36msudo $(basename "$0")" >&2
exit 1
fi
launchd_bluetoothd=$(launchctl list|/usr/bin/grep com.apple.bluetoothd|/usr/bin/awk -F ' ' '{ print $3 }')
if [ $launchd_bluetoothd != "com.apple.bluetoothd" ]; then
echo "com.apple.bluetoothd LaunchDaemon was not found." >&2
exit 1
fi
echo "Restarting bluetoothd. Bluetooth devices will reconnect momentarily." >&2
launchctl stop com.apple.bluetoothd && launchctl start com.apple.bluetoothd
exit 0
@breiter
Copy link
Author

breiter commented Jan 13, 2022

This fixes wonky bluetooth keyboard function key mappings and Continuity when it stops working.

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