Acidham / alfred-airpod-connector

Alfred Workflow to connect/disconnect AirPods (Airpod1/2, Airpod Pro) and Powerbeats Pro
35 stars 7 forks source link

[Bug] Crashes on macOS Monterrey 12.2 #5

Closed 3raxton closed 2 years ago

3raxton commented 2 years ago

Hey @Acidham thanks for your hard work on this workflow! I've been using it for quite some time and it's great. As of late, however, it hasn't been working correctly for me. I took a look at the log and this is what is output:

[18:45:29.274] Logging Started...

[18:45:30.619] AirPods Connector[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.2B48DE9F-77F2-4429-9DCE-63CA7C8AC5FE%3E2378081C-843E-45C6-B549-1B0FFD46EF7C)] Queuing argument '(null)'

[18:45:30.826] AirPods Connector[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.2B48DE9F-77F2-4429-9DCE-63CA7C8AC5FE%3E2378081C-843E-45C6-B549-1B0FFD46EF7C)] Script with argv '(null)' finished

[18:45:30.828] ERROR: AirPods Connector[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.2B48DE9F-77F2-4429-9DCE-63CA7C8AC5FE%3E2378081C-843E-45C6-B549-1B0FFD46EF7C)] Code 1: Traceback (most recent call last):
  File "/Users/Prized/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2B48DE9F-77F2-4429-9DCE-63CA7C8AC5FE/airp.py", line 81, in <module>
    main()
  File "/Users/Prized/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2B48DE9F-77F2-4429-9DCE-63CA7C8AC5FE/airp.py", line 61, in main
    for ap_name, status in get_paired_airpods().items():
  File "/Users/Prized/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2B48DE9F-77F2-4429-9DCE-63CA7C8AC5FE/airp.py", line 43, in get_paired_airpods
    if connected_devices:  # macos >= 12.3

UnboundLocalError: local variable 'connected_devices' referenced before assignment

I'm unsure what next steps to take here. Would you mind helping me sort this out? Thanks!

(For the record I am unsure if this is related to Monterrey but as of updating to Monterrey it has not worked)

Acidham commented 2 years ago

In macOS 12.3 Apple changed the BT object and I had to adapt the code. Unfortunately, macOS 12.2 was no longer available and it may well be that some bugs have crept in.

Please download this version v1.2.10.1 and let me know: https://github.com/Acidham/alfred-airpod-connector/raw/master/AirPods%20Connector.alfredworkflow

3raxton commented 2 years ago

That does the trick, thanks! Be well!