Created
August 8, 2023 10:47
-
-
Save jaygooby/ab9ad6874ba4970a2cc0569a83c739d1 to your computer and use it in GitHub Desktop.
Toggle your Nothing ear (1) as the active bluetooth device
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
# Totally stolen from | |
# https://gist.github.com/ieatfood/814b065964492f71f728da59a47413bc | |
# | |
# Export this applescript as an app, and then just double click to toggle on & off | |
use framework "IOBluetooth" | |
use scripting additions | |
set blueToothDevice to "Nothing ear (1)" | |
on getFirstMatchingDevice(deviceName) | |
repeat with device in (current application's IOBluetoothDevice's pairedDevices() as list) | |
if (device's nameOrAddress as string) contains deviceName then return device | |
end repeat | |
end getFirstMatchingDevice | |
on toggleDevice(device) | |
if not (device's isConnected as boolean) then | |
device's openConnection() | |
return "Connecting " & (device's nameOrAddress as string) | |
else | |
device's closeConnection() | |
return "Disconnecting " & (device's nameOrAddress as string) | |
end if | |
end toggleDevice | |
return toggleDevice(getFirstMatchingDevice(blueToothDevice)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment