Jump to content
vegardinho

Bluetooth Controller

Recommended Posts

Posted (edited)

Hi,

 

I was a bit tired of handling all my bluetooth devices manually, and couldn't find any cover-all bluetooth workflows out there, so I made this one.

 

alfredbluetooth.gif

 

Features:

  • Turn on/off/toggle bluetooth
  • Connect to device from list of paired bluetooth devices
  • Set favorite device for quick access
  • User friendly notifications for all actions

 

Dependencies (see README on git repo):

  • Blueutil
  • Python3

 

Feel free to give me feedback, and report bugs if you find any.

 

Githubhttps://github.com/vegardinho/alfred_bluetooth_controller

Download: https://github.com/vegardinho/alfred_bluetooth_controller/releases/latest

 

Cheers,

Vegard

Edited by vegardinho
Edited link to release

Share this post


Link to post

Hi,

 

This looks like a workflow that I'll get a lot of use out of. I'm having a bit of trouble with it, though. Specifically when I use btd + devicename, or try to configure btsetfavorite, it only gives me the option to search Google for "btd devicename" etc. 

 

I tried following your instructions to install blueutil and python, so I don't think the problem is there. 

 

I'm using all the latest stable versions of all software on an MBP, if that matters.

Share this post


Link to post
Posted (edited)
6 hours ago, sr_navarre said:

Hi,

 

This looks like a workflow that I'll get a lot of use out of. I'm having a bit of trouble with it, though. Specifically when I use btd + devicename, or try to configure btsetfavorite, it only gives me the option to search Google for "btd devicename" etc. 

 

I tried following your instructions to install blueutil and python, so I don't think the problem is there. 

 

I'm using all the latest stable versions of all software on an MBP, if that matters.

Hi,

 

Glad to hear the workflow is useful!

 

Can you make sure you are typing the same thing as in the gif above? The format should be "btd", then space, followed by whatever device you are searching for. Just typing "btd" should give you a list of all the previously paired bluetooth devices.

 

Also keep in mind that currently only results that are exact matches from the start of the word, are matched. That means "device" will not match the device "mydevice", but "mydev" will. I am working on changing this, but currently this is a limitation to the workflow you have to account for. 

Update: The newest release now includes smart search, i.e. it matches ever item where every search argument is found in the device name ("device" will now match "mydevice"; so will "device 45" for hypothetical device "mydevice tx45")

 

If this doesn't help you: Could you run the workflow while in debug mode? Find the workflow in preferences, click the little spider on the top right, and then open the alfred search bar and type in what you would type to get the error. Copy whatever shows up in the debug text field, and paste it in the forum, so I can have a look at it.

 

I've also already killed a bug, so I recommend you download the new release anyway (though the fix it is not related to your problem).

 

Hope that helps!

 

Edited by vegardinho
Updated info from new release

Share this post


Link to post

Thank you for getting back to me. I'm pasting the results from the debugger below. The first is from running btd, the second is btsetfavorite.

 

[21:51:52.387] Logging Started...

[21:52:01.294] Bluetooth Controller[Script Filter] Queuing argument '(null)'

[21:52:01.513] Bluetooth Controller[Script Filter] Script with argv '(null)' finished

[21:52:01.516] ERROR: Bluetooth Controller[Script Filter] Code 1: Traceback (most recent call last):

  File "./return_device_json.py", line 41, in <module>

    device['address'], device_name) + "},")

AttributeError: 'NoneType' object has no attribute 'lower'

___________________________________________________________________________________________________

[21:52:40.137] Bluetooth Controller[Script Filter] Queuing argument '(null)'

[21:52:40.320] Bluetooth Controller[Script Filter] Script with argv '(null)' finished

[21:52:40.322] ERROR: Bluetooth Controller[Script Filter] Code 1: Traceback (most recent call last):

  File "./return_device_json.py", line 41, in <module>

    device['address'], device_name) + "},")

AttributeError: 'NoneType' object has no attribute 'lower'

Share this post


Link to post
Posted (edited)
7 hours ago, sr_navarre said:

Thank you for getting back to me. I'm pasting the results from the debugger below. The first is from running btd, the second is btsetfavorite.

 

[21:51:52.387] Logging Started...

[21:52:01.294] Bluetooth Controller[Script Filter] Queuing argument '(null)'

[21:52:01.513] Bluetooth Controller[Script Filter] Script with argv '(null)' finished

[21:52:01.516] ERROR: Bluetooth Controller[Script Filter] Code 1: Traceback (most recent call last):

  File "./return_device_json.py", line 41, in <module>

    device['address'], device_name) + "},")

AttributeError: 'NoneType' object has no attribute 'lower'

___________________________________________________________________________________________________

[21:52:40.137] Bluetooth Controller[Script Filter] Queuing argument '(null)'

[21:52:40.320] Bluetooth Controller[Script Filter] Script with argv '(null)' finished

[21:52:40.322] ERROR: Bluetooth Controller[Script Filter] Code 1: Traceback (most recent call last):

  File "./return_device_json.py", line 41, in <module>

    device['address'], device_name) + "},")

AttributeError: 'NoneType' object has no attribute 'lower'

 

It seems one of your devices has a non-existing name (type None), which is what causes the crash. I've now updated to check whether name actually exists before attempting to call any actions on it. Version 1.2.2 (out now) should fix the problem for you.

 

I'm a little unsure why the device doesn't appear to have a name; you could try running "blueutil --paired --format json-pretty" (note: double dashes) manually, to see if you can spot something abnormal in the output.

Edited by vegardinho

Share this post


Link to post
Posted (edited)

I have Blueutil and Python3 (running 'python3 --version' in terminal outputs 'Python 3.7.6') installed using Homebrew, but it does not work and the debugger reports: 

[17:17:30.841] ERROR: Bluetooth Controller[Script Filter] Code 127: /bin/bash: python3: command not found

I'm using version 1.2.2 of the workflow on Alfred 4.0.9 and macOS 10.14.6. Any tips how it may be fixed? 

Edited by cands

Share this post


Link to post
5 hours ago, sr_navarre said:

It seems to work just fine now. Thanks! It's awesome when a developer is so responsive.

 

Great to hear it works! I guess time is one of the benefits of these corona times;)

Share this post


Link to post
Posted (edited)
7 hours ago, cands said:

I have Blueutil and Python3 (running 'python3 --version' in terminal outputs 'Python 3.7.6') installed using Homebrew, but it does not work and the debugger reports: 


[17:17:30.841] ERROR: Bluetooth Controller[Script Filter] Code 127: /bin/bash: python3: command not found

I'm using version 1.2.2 of the workflow on Alfred 4.0.9 and macOS 10.14.6. Any tips how it may be fixed? 

 

It seems bash is not finding your Python3 interpreter, so it is probably located somewhere else than where mine is. I've added a fix to search for logical placement of python interpreter, so hopefully that does it (v.1.2.3).

 

If the fix doesn't work, make sure python3 is working (entering "python3" in terminal should suffice), as well as check where the interpreter lies ("which python"). You could also do a clean install of python3, I had a lot of different versions of python lying around, some by homebrew, and some old; and that eventually caused a lot of trouble, which was straightened out by the clean install.

Edited by vegardinho

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...