raycast / extensions

Everything you need to extend Raycast.
https://developers.raycast.com
MIT License
5.18k stars 2.88k forks source link

[Toothpick] Disconnect does not work on macOS 14.5 #12337

Closed roele closed 3 months ago

roele commented 3 months ago

Extension

https://www.raycast.com/VladCuciureanu/toothpick

Raycast Version

1.73.3

macOS Version

14.5

Description

Device does not disconnect successfully (via AppleScript) after update to macOS 14.5. UI reports Device disconnected successfully but device stays connected. This issue does not occur with the experimental blueutil backend.

Steps To Reproduce

  1. Connect an audio device
  2. (Play some music)
  3. Disconnect device
  4. Observe that device is still connected

OS: macOS 14.5 Bluetooth Backend: AppleScript

Current Behaviour

Raycast reports Device disconnected successfully but device is still connected.

Expected Behaviour

Device is disconnected successfully with AppleScript backend.

raycastbot commented 3 months ago

Thank you for opening this issue!

🔔 @VladCuciureanu @briankosw @VladCuciureanu @sxn @pernielsentikaer @rspeicher you might want to have a look.

💡 Author and Contributors commands The author and contributors of `VladCuciureanu/toothpick` can trigger bot actions by commenting: - `@raycastbot close this issue` Closes the issue. - `@raycastbot rename this issue to "Awesome new title"` Renames the issue. - `@raycastbot reopen this issue` Reopens the issue. - `@raycastbot assign me` Assigns yourself to the issue. - `@raycastbot good first issue` Adds the "Good first issue" label to the issue.
VladCuciureanu commented 3 months ago

Hey Roland! This is a known issue whose only (somewhat) fix is using the blueutil backend, but you figured that out already. Sadly this is due to the fact that AppleScript is not being maintained properly by Apple and it's unlike I'll have the time to investigate and hack on this further.

roele commented 3 months ago

The interesting thing is that running the scripts via Automator seems to work fine. So i wonder where it fails exactly... if i find some time and figure out how to debug Raycast extensions, i'll have a closer look.

use framework "IOBluetooth"
use scripting additions

on getFirstMatchingDevice(deviceMacAddress)
    repeat with device in (current application's IOBluetoothDevice's pairedDevices() as list)
        if (device's addressString as string) contains deviceMacAddress then return device
    end repeat
end getFirstMatchingDevice

getFirstMatchingDevice

on disconnectDevice(device)
    if (device's isConnected as boolean) then
        set result to device's closeConnection()
        return result
    else
        return -1
    end if
end disconnectDevice

disconnectDevice(getFirstMatchingDevice("<MAC-ADDR>"))
VladCuciureanu commented 3 months ago

It would be awesome if you could take a look! It also worked for me inside Automator. A hint would be to look at what blueutil does. They have a hack for this that I've been unable to implement. Something regarding the timing of the instructions or some params passed into a constructor (don't remember as so much time passed since).

roele commented 3 months ago

@VladCuciureanu Had a quick look and was able to find a workaround which seems to work (at least for me). You can find the PR at https://github.com/VladCuciureanu/Toothpick/pull/5

VladCuciureanu commented 3 months ago

LGTM! Will merge it upstream as soon as I clone the main repo

VladCuciureanu commented 3 months ago

Merged!

@raycastbot close this issue.