Created
October 7, 2016 19:53
-
-
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
This file contains hidden or 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/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And how could you make new connections on Mac using python and pyobjc?