Connect to AirPods widget doesn't work if the Volume menu is disabled

I got a new error now for some reason.

Remove the entire line that begins with set volumeMenu to... . I don't know why that's even there, actually. Wow.

Now I know what the issue was. You don't have the volume menu enabled, and it was checking for that for some stupid reason.

Congratulations, you just found the very first super edge case bug!!! I will fix this in the next experimental version. But manually remove that line from both AirPods widgets and you should be good to go.

I feel famous. The menu now opens with the button. I'm surprised this wasn't a more common occurrence for people.

1 Like

Wooohooo!!!

We'll never know how many of the "AirPods widget isn't working" posts were actually people with your exact issue... but now I will make sure to encourage people with the stable version having issues with their AirPods widget to double check that they have both bluetooth and volume menus enabled, as a workaround in the meantime.

Current stable version is now starting to show its age, I better pick up the pace on this new one...!

Hello, thank you for your nice work!

I also have a problem connecting airpods.

I installed the new version (2.720) and still cannot connect airpods.

When I manually run the script in (connect and disconnect), I can get the correct return value "deviceConnected in 'Connect to Airpods: Script' widget" or "Script: Connect in 'Connect to Airpods'" depending on my connection status. However, nothing happens when I push the buttons nor menu bar changes.

As a novice, I cannot find any code segments trying to connect to airpods. There exist only connection check part.

I appreciate your time and assistance.

The touchbar widget script is as follows (nothing changed):

============================================

use framework "Foundation"

use framework "IOBluetooth"

use scripting additions

set pairedNames to (( current application's IOBluetoothDevice's pairedDevices())'s valueForKey:"nameOrAddress") as list

set connectedValue to (( current application's IOBluetoothDevice's pairedDevices())'s valueForKey:"connected") as list

set btInfo to {}

set i to 0

repeat with i from 1 to count pairedNames

set btInfo to btInfo & ( item i of pairedNames & ", " & item i of connectedValue) as list

end repeat

set i to 0

set deviceConnected to false

repeat with i from 1 to count btInfo

if item i of btInfo contains "AirPods" and item i of btInfo contains ", 1" then

set deviceConnected to true

else if item i of btInfo contains "The Temmie Flakes" and item i of btInfo contains ", 1" then

set deviceConnected to true

end if

end repeat

return deviceConnected

============================================

When I see the previous versions, they included 'click' commands to connect airpods while this version does not have any clicks which is why there is no difference when clicked, as I think.

@GoldenChaos

You're clicking the wrong spot, that's not the script that clicks the button, that's the one that turns the icon blue :slight_smile: that's why there's no clicks in it, haha.

You want this script, click the gear in the red box:

Thanks! I found the correct place where the 'click' commands exist.

Since there was no reaction when I pushed the button, I checked the script and got this error where the highlighted part was a problem.

When I successfully used a connect/disconnect airpods button in another preset, the code segment
if exists menu item "Connect" then
was not like this but
if exists menu item "연결" then
since my mac is using Korean language not English.

For the current problem, since the code execution cannot reach the 'click' segment, I think it is not related to the language of my mac.

Moreover, as the simplest check, I tried the following code whose result is 'missing value'.

Additionally, I am uploading some test results I conducted for debugging.




Any idea for this error?

Thank you for your effort.

Seems like the title changes if you are working on a non-english system. The missing value output should be ok, as there is no return value here.

Thank you for the kind reply.

You said 'the title changes'. Can you tell me what kind of title you mean here? I have no clue which 'title' I need to change.

I understood that you had it working with "연결" as title in another preset? Or has that also stopped working?

Let me just give sime tips here,
I think its a language issue. Since the scripts clicks through the menus by the english name, It can’t find the menus on his machiene because of the change in language.

I’ve had this issue when I updated to mojave. They made the menu labels more accuratley follow British english spelling, so many of the American-based widgets broke down. (e.g. Color → Colour) It was quite an easy fix, I just added an “Or Colour” or replaced the ID name with British spelling.

@Clark93, If you can, could you try switching your language to english and see if thst works? If that does, we know the issue is the language and we can work further from there.

Also a screenshot of the korea. bluetooth menu would be helpful too!

Sorry for the late reply. I could use another preset which had "연결" the script. However, it is also not working as Golden Chaos.

Sorry for the late reply.

I changed my language as you said like the below screenshot and it did not work with the same error.

For your information, the error window when I run the script is as follows.

The Korean bluetooth menu is as follows.

Could you also send the current problematic code as well?

(inside the third image)

Thanks!

I think you mean the code in the second image which is the below code.

============================================

tell application "System Events" to tell process "SystemUIServer"

set btMenu to ( first menu bar item whose description is "bluetooth") of menu bar 1

click btMenu

tell ( first menu item whose title contains "AirPods") of menu of btMenu

click

tell menu 1

if exists menu item "Connect" then

click menu item "Connect"

else if exists menu item "Disconnect" then

click menu item "Disconnect"

else

-- Look for a device with a different name

tell ( first menu item whose title contains "The Temmie Flakes") of menu of btMenu

click

tell menu 1

if exists menu item "Connect" then

click menu item "Connect"

else if exists menu item "Disconnect" then

click menu item "Disconnect"

else

-- We didn't find ANY of our devices :cry:

key code 53 --escape

end if

end tell

end tell

end if

end tell

end tell

end tell

============================================