bmunoz89 / alfred-wf-bluetooth-manager

Connect and disconnect a bluetooth device easily
https://www.alfredforum.com/topic/13493-bluetooth-manager-connect-and-disconnect-a-bluetooth-device-easily/
MIT License
62 stars 0 forks source link

bm, bds and bcs keywords cannot be find after updated to macOS 12.3 #17

Closed victorchor2868 closed 2 years ago

victorchor2868 commented 2 years ago

Hi,

I want to report an issue, after updating to macOS 12.3, bm, bds, and bcs cannot be found in the Alfred search.

CleanShot 2022-03-17 at 14 30 36@2x CleanShot 2022-03-17 at 14 30 50@2x CleanShot 2022-03-17 at 14 31 02@2x
zcysxy commented 2 years ago

I guess this workflow is based on Python2 and it is removed in Monterey 12.3.

zcysxy commented 2 years ago

Since many of my Alfred workflows rely on Python2, I found a workaround to fix the issue.

  1. Install Python2 using pyenv. The binary is in Users/USER_NAME/.pyenv/versions/VER_NUM/bin/python, where USER_NAME is your user name and VER_NUM is the version number of the installed Python2.
  2. Change the global python pyenv uses:
    pyenv global VER_NUM

    Notice that since I don't use pyenv elsewhere, I just change the global python it uses permanently. If you use pyenv elsewhere, you should change it back to system every time.

  3. Open the workflow folder, make the following change in every python script

    # Find this line
    cmd = ['/usr/bin/python', ...]
    
    # Replace the python executable with pyenv python
    cmd = ['/Users/USER_NAME/.pyenv/versions/VER_NUM/bin/python', ...]
  4. Make the following change in info.plist

    # Find this line
    /usr/bin/python XXX.py ...
    
    # Replace the python executable with pyenv python command
    /opt/homebrew/bin/pyenv exec python XXX.py ...

    Change the pyenv path if you don't install it using Homebrew.

Since in steps 3 and 4 you need to change every occurrence of the original python executable, I recommend opening the workflow folder using a text editor like VS Code to do the global search to find all the occurrences.

victorchor2868 commented 2 years ago

I'm sorry, I am not a programmer, can I ask you how to do step 2? for step 1, I can't find the binary. will you release a new version for the workflow?

CleanShot 2022-03-20 at 21 23 51@2x
zcysxy commented 2 years ago

@victorchor2868 I can release a new version, but the problem is the missing python, so you still have to configure the python. Let me give you a step-by-step example for your case.

  1. Install pypy2.7-7.3.6 (an alternative to python):

    pyenv install pypy2.7-7.3.6
  2. Set pypy2.7-7.3.6 as global python

    pyenv global pypy2.7-7.3.6
  3. Type

    which pyenv

    make sure the output is /opt/homebrew/bin/pyenv. Then type

    whoami

    make sure the output is victorchor.

  4. In Alfred setting, right-click the Bluetooth manager tab and choose Open in Finder, replace the info.plist with this file: info.txt. Remember to rename this file to info.plist since GitHub doesn't allow to attach .plist file.

  5. Go into the workflow folder, replace the background.py and workflow.py with these two files respectively

That's all.

victorchor2868 commented 2 years ago

It's working, thanks for your explanation. thanks a lot

CleanShot 2022-03-21 at 13 13 01@2x
bmunoz89 commented 2 years ago

Fixed in the last release and I leave some notes in the README as well.

krishpop commented 2 years ago

I find that switching the default system python to Python 2 (especially after all of this effort to move to Python 3) is counter productive, as it may affect other applications downstream. A better solution would be a) adding a variable to set the python binary, or b) simply setting the python binary in the workflow scripts to /usr/local/bin/python2.7 to specify the python version being used (this worked in my case). This creates less ambiguity and removes the need to override the system python.

bmunoz89 commented 2 years ago

well that's why is only recommended if you have updated your os to monterey, otherwise you can use the previous version https://github.com/bmunoz89/alfred-wf-bluetooth-manager/releases/download/2.4.1/Bluetooth.manager.alfredworkflow since there is no new feature it will work in the same way and also your system python should be here /bin/python and not here /usr/local/bin/python which is the expected path