Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 Dec 17, 2021

curl -L -o bluetooth-restart https://gist.github.com/breiter/9f8aeeb438d9eb6c93aac32988414b9e/raw/c581159b3055a1e443975a65dbdeef30c176368a/bluetoohtd-restart.sh
chmod +x bluetooth-restart 
sudo ./bluetooth-restart

@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