Created
January 23, 2022 21:14
-
-
Save luckman212/efec7df3fdea3163341ebbb7144c8415 to your computer and use it in GitHub Desktop.
When Airdrop stops working, this might fix it without requiring a reboot...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# requires blueutil: `brew install blueutil` | |
if ! sudo -v ; then | |
echo requires root | |
exit | |
fi | |
function dots() { | |
for (( c=$1; c>0; c-- )); do | |
echo -n '.' | |
sleep 1 | |
done | |
echo "done" | |
} | |
# make sure BrowseAllInterfaces is false | |
echo -n "setting com.apple.NetworkBrowser prefs..." | |
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool false | |
defaults remove com.apple.NetworkBrowser DisableAirDrop 2>/dev/null | |
echo "done" | |
# bounce Bluetooth daemon | |
echo -n "kickstarting com.apple.bluetoothd" | |
sudo launchctl kickstart -kp system/com.apple.bluetoothd >/dev/null | |
dots 3 | |
# turn Bluetooth and WiFi off | |
echo -n "turning off Bluetooth and WiFi" | |
blueutil -p 0 | |
networksetup -setairportpower en1 off | |
dots 3 | |
# turn Bluetooth and WiFi on | |
echo -n "turning on Bluetooth and WiFi" | |
blueutil -p 1 | |
networksetup -setairportpower en1 on | |
dots 3 | |
echo | |
echo "try AirDrop again!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a shell script. Save it as plaintext (I recommend Sublime Text for this, or VSCode). Click the "raw" button on the top right of this page to get the plain text version.
A good place to put it is
/usr/local/bin/airdropfix.sh
but anywhere in your$PATH
is fine.Open a Terminal and type
Now you should be able to type
airdropfix.sh
in any Terminal and the script will run.