tilmanginzel / alfred-bluetooth-workflow

Yet another Alfred workflow to connect / disconnect Bluetooth devices
MIT License
189 stars 8 forks source link

Sonoma #36

Closed austschn closed 9 months ago

austschn commented 10 months ago

Hey @tilmanginzel - It's me again! I just updated to Mac OS Sonoma, and it seemed to cause more issues. Please see below for the debugger logs when running the app. Any recommendations to fix?

'[09:46:37.607] Logging Started... [09:46:40.878] Bluetooth Connector[Script Filter] Queuing argument '' [09:46:41.269] Bluetooth Connector[Script Filter] Queuing argument '' [09:46:41.491] Bluetooth Connector[Script Filter] Script with argv '(null)' finished [09:46:41.496] ERROR: Bluetooth Connector[Script Filter] Code 1: . 09:46:41 workflow.py:2093 DEBUG ---------- Bluetooth Connector (0.12.0) ---------- 09:46:41 workflow.py:1483 DEBUG reading settings from /Users/SXH/Library/Application Support/Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/settings.json 09:46:41 workflow.py:2394 INFO checking for update ... 09:46:41 background.py:233 DEBUG [workflow_update_check] command cached: /Users/SXH/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/workflow_update_check.argcache 09:46:41 background.py:237 DEBUG [workflow_update_check] passing job to background runner: ['/usr/local/bin/python3', '-m', 'workflow.background', 'workflow_update_check'] . 09:46:41 workflow.py:2093 DEBUG ---------- Bluetooth Connector (0.12.0) ---------- 09:46:41 background.py:243 DEBUG [__workflow_update_check] background job started 09:46:41 workflow.py:2114 ERROR Expecting value: line 1 column 1 (char 0) Traceback (most recent call last): File "/Users/SXH/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.337F9110-8884-4AA2-9518-D4905149FD00/workflow/workflow.py", line 2107, in run func(self) File "/Users/SXH/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.337F9110-8884-4AA2-9518-D4905149FD00/alfred_bluetooth_workflow.py", line 40, in main devices = _read_devices() ^^^^^^^^^^^^^^^ File "/Users/SXH/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.337F9110-8884-4AA2-9518-D4905149FD00/alfred_bluetooth_workflow.py", line 14, in _read_devices devices_raw = json.loads(proc.stdout.read()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 09:46:41 workflow.py:2136 DEBUG ---------- finished in 0.101s ---------- [09:46:41.497] Bluetooth Connector[Script Filter] { "items": [ { "title": "Error in workflow 'Bluetooth Connector'", "subtitle": "Expecting value: line 1 column 1 (char 0)", "valid": false, "icon": { "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns" } } ] }`

bm-w commented 10 months ago

Same here (Sonoma 14.0 23A344, Bluetooth Connector 0.12.0), although it did work for some time after upgrading. The problem seems to occur in this call to blueutil. I added some lines to debug, and got return code -6 with empty STDOUT & STDERR. Calling that same blueutil executable myself from the command line works just fine.

austschn commented 10 months ago

Hey @bm-w, thank you for the answer. I'm afraid I am not that technical to get that to work. The last time I had this issue there was a basic solution, hopefully something like that will be up soon!

tobiasgerstenberg commented 10 months ago

Same issue here, just adding information from my log, too.

I get the following error message on Sonoma 14.0 (23A344).

blt_error

Here is the log.

[10:27:16.238] Logging Started...
[10:27:21.332] Bluetooth Connector[Script Filter] Queuing argument ''
[10:27:21.445] Bluetooth Connector[Script Filter] Script with argv '(null)' finished
[10:27:21.448] ERROR: Bluetooth Connector[Script Filter] Code 1: .
10:27:21 workflow.py:2093 DEBUG    ---------- Bluetooth Connector (0.12.0) ----------
10:27:21 workflow.py:1483 DEBUG    reading settings from /Users/tobiasg/Library/Application Support/Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/settings.json
10:27:21 workflow.py:2399 DEBUG    update check not due
10:27:21 workflow.py:1717 DEBUG    loading cached data: /Users/tobiasg/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/de.tilmanginzel.alfred.bluetooth/__workflow_latest_version.pickle
10:27:21 workflow.py:2114 ERROR    Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/Users/tobiasg/Dropbox/work/alfred/Alfred.alfredpreferences/workflows/user.workflow.5E5BC5F6-A469-4356-865B-0091099B99C1/workflow/workflow.py", line 2107, in run
    func(self)
  File "/Users/tobiasg/Dropbox/work/alfred/Alfred.alfredpreferences/workflows/user.workflow.5E5BC5F6-A469-4356-865B-0091099B99C1/alfred_bluetooth_workflow.py", line 40, in main
    devices = _read_devices()
              ^^^^^^^^^^^^^^^
  File "/Users/tobiasg/Dropbox/work/alfred/Alfred.alfredpreferences/workflows/user.workflow.5E5BC5F6-A469-4356-865B-0091099B99C1/alfred_bluetooth_workflow.py", line 14, in _read_devices
    devices_raw = json.loads(proc.stdout.read())
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
10:27:21 workflow.py:2136 DEBUG    ---------- finished in 0.047s ----------
[10:27:21.450] Bluetooth Connector[Script Filter] {
  "items": [
    {
      "title": "Error in workflow 'Bluetooth Connector'",
      "subtitle": "Expecting value: line 1 column 1 (char 0)",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

Cheers,

Tobi

tilmanginzel commented 10 months ago

Hi, thanks for notifying me. Every MacOS release, something breaks again... Will try to take a look at this in the coming week.

austschn commented 10 months ago

Understand. We appreciate you, @tilmanginzel!

akaralar commented 10 months ago

The script works as is. The problem is Alfred does not have bluetooth permissions. Adding Alfred to the list of apps in System Settings > Privacy & Security > Bluetooth restores the functionality.

Before doing this I also ran

./blueutil --paired --format=JSON

from the workflow folder and I was presented by an alert that I clicked allow without reading. So if giving Alfred bluetooth permission does not work try that and accept that alert as well but I believe the alert was related to bluetooth permission for iTerm and does not have anything to do with the workflow working in Alfred.

a-rock-lobster commented 10 months ago

🤦‍♂️ Thanks!

austschn commented 10 months ago

The script works as is. The problem is Alfred does not have bluetooth permissions. Adding Alfred to the list of apps in System Settings > Privacy & Security > Bluetooth restores the functionality.

Before doing this I also ran

./blueutil --paired --format=JSON

from the workflow folder and I was presented by an alert that I clicked allow without reading. So if giving Alfred bluetooth permission does not work try that and accept that alert as well but I believe the alert was related to bluetooth permission for iTerm and does not have anything to do with the workflow working in Alfred.

This worked like a charm. Back online - thank you all for your help!

tilmanginzel commented 9 months ago

Sorry this went a bit under the radar. Thanks @akaralar for the solution, can now confirm it also worked for me. 👍