Hi,
Thanks for this script. I really love it and I find it very useful!
While using this widget, I did find a small bug.
To replicate it:
- Have another bluetooth device connected (like a mouse or keyboard) and make sure it's before your AirPods on the bluetooth list.
- Have your AirPods second or third or anywhere after the first bluetooth device on the list and make sure it is not connected.
- The widget will display 'Not Connected' instead of 'x'.
I believe this is a bug with your logic in looping. It seems like the script hits the if statement on the third line here and returns checkBattery() because the bluetooth devices before the AirPods are Connected: Yes.
repeat numberOfDevices times --loop through each devices checking for Connected string if item counter of myList contains "Ivan's AirPods" then if item counter of myList contains "Connected: Yes" then return checkBattery() else if item counter of myList contains "Connected: No" then return " " else display dialog "Error Parsing" --this shouldn't happen end if end if set counter to counter + 1 end repeat
I don't have any experience writing Apple Script, but I might try to debug this on the weekend.
UPDATE:
Found the fix. For anybody using this widget in the future, there are three strings you will need to change.
- Replace the two occurrences of "Ivan's AirPods" with "Your AirPod Name"
- Replace the one occurrence of "name:" with "You AirPod Name:"