Skip to content

Instantly share code, notes, and snippets.

@pudquick
Created October 7, 2016 19:53
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pudquick/5a1aaa2effe3825368db4c1925924bba to your computer and use it in GitHub Desktop.
Save pudquick/5a1aaa2effe3825368db4c1925924bba to your computer and use it in GitHub Desktop.
Remove all Bluetooth devices from OS X / macOS in the style of the Bluetooth debug menu "Remove all devices" with python and pyobjc
#!/usr/bin/python
from Foundation import NSBundle
IOBluetooth = NSBundle.bundleWithIdentifier_('com.apple.Bluetooth')
IOBluetoothDevice = IOBluetooth.classNamed_('IOBluetoothDevice')
# remove configured devices
try:
devices = list(IOBluetoothDevice.configuredDevices())
except:
devices = []
for device in devices:
try:
device.remove()
except:
pass
# remove paired devices
try:
devices = list(IOBluetoothDevice.pairedDevices())
except:
devices = []
for device in devices:
try:
device.remove()
except:
pass
# remove favorite devices
try:
devices = list(IOBluetoothDevice.favoriteDevices())
except:
devices = []
for device in devices:
try:
device.remove()
except:
pass
@0xYelshayeb
Copy link

And how could you make new connections on Mac using python and pyobjc?

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