Toggle AirPods ANC with touch bar

Hi everyone,

I've stumbled across this app that allows to put a listening mode toggle in the touch bar or status bar. Can this somehow be replicated using BTT?

2 Likes

second that

Hmmm... Ill have to look into that. I bet I can control that option. I normally just switch between using long squeeze on AirPods.

Found this code if your want to auto switch between Noise Cancellation and Transparency

One issue, I get an error. Not sure what im missing here, but the menu item isn't getting selected properly. I had it working a few times, then fails.

tell application "System Events"
    tell process "SystemUIServer"
        click (menu bar item 1 of menu bar 1 whose description contains "volume")
        try
            click menu item "your AirPods name" of menu 1 of result
            if value of attribute "AXMenuItemMarkChar" of menu item "Transparency" of menu 1 of result is "✓" then
                click menu item "Noise Cancellation" of menu 1 of result
            else
                click menu item "Transparency" of menu 1 of result
            end if
        on error
            key code 53
            click (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
            click menu item "your AirPods name" of menu 1 of result
            click menu item "Connect" of menu 1 of result
        end try
    end tell
end tell

Thanks for trying to help! I've tried several of those scripts that are supposed to do the trick, but for some reason they don't seem to work. I'm also getting an error and the toggle rarely works (seems more or less random). Maybe something changed since Catalina and those scripts were written for an older macOS, or I don't know :man_shrugging:

An actual ANC toggle implementation in BTT would be pretty nice.

I have looked for what changes have happened in the OS, nothing found yet.

Hi so I think I've found a round about way of solving this but it's actually surprisingly simple, so hopefully it works for you too:

On the app you linked above it allows you to assign a keyboard shortcut to toggle ANC/transparency mode. So all I did was use a BTT action to press this same keyboard combination that set up in noise buddy to then toggle ANC. You can even go further and add two actions to it to make it play/pause the music at the same time as toggling ANC. Something i've wanted to do for so so long.

Here's my personal set up. I, by the way, prefer trackpad shortcuts as it saves me lifting my hand up to the touch bar all the time (all about the time savings). But anyway I have set a tap at the bottom middle of trackpad to press the keyboard combination controlQ (the keyboard shortcut I set up in that noise buddy app you linked) and then set the BTT to also play/pause music when i tap the same part of the trackpad under one trigger basically. So when I press the button now it pauses music and also sets my airpods to transparency when for when someone walks in the room- and tap again to start music back up and activate ANC. It works a charm, just make a BTT touch bar button for it instead, the concept will be identical.

If someone knows a quick way of achieving the same thing at the same time as toggling play/pause through maybe using a siri shortcuts or something for iPhone please please let me know. Because I need this.

Hope this works for you.

Thanks for your suggestion! I thought of this as well, and I guess it's a great workaround until we have a native ANC toggle support in BTT. I was just trying to figure out how not to have two separate apps running for this, but rather have everything done with BTT :smile:

I've noticed in defaults read /Library/Preferences/com.apple.Bluetooth there is a line for 'Listening Mode' which changes from 1 to 3 depending on NC or Transparency. Hope this helps

Thanks for the hint. The app I mentioned above (NoiseBuddy) seems to be open source, so maybe someone who's into coding could check out what it does and find a way to replicate that with BTT using AppleScripts :smile:

Hey, great workflow.
I'm using Banana on iOS to do this exactly, play/pause synced with ANC/Transparency.

You'll need to jailbreak your iPhone though.

I have a script to report which mode is enabled. Still working out how to set up the trigger script to toggle between each mode.

set deviceAddress to "b4-40-a4-e9-52-6b"

set plistFile to "/Library/Preferences/com.apple.Bluetooth.plist"

tell application "System Events"

set listenMode to the value of property list item "ListeningMode" of property list item deviceAddress of property list item "DeviceCache" of property list file plistFile as string

if listenMode is "1" then

return "OFF"

else if listenMode is "2" then

return "ANC"

else if listenMode is "3" then

return "TRANS"

end if

end tell

can this be done with Beats Studio 3?

I get the error below: Might be in binary format?

error "Can’t make «class valL» of «class plii» "ListeningMode" of «class plii» "Ee4-90-fd" of «class plii» "DeviceCache" of «class plif» "/Library/Preferences/com.apple.Bluetooth.plist" of application "System Events" into type string." number -1700 from « class valL» of « class plii» "ListeningMode" of « class plii» "Ee4-9" of « class plii» "DeviceCache" of « class plif» "/Library/Preferences/com.apple.Bluetooth.plist" to string

A MAC address would be formatted as xx-xx-xx-xx-xx-xx
In this error it is looking like that formatting is incorrect.

I truncated my Mac address.. Thats not the issue.

1 Like

Hmm.. ok. I cannot think of what is causing the issue off the top of my head but I'll do some more research. The script has been working flawlessly for me

What OS are you running? 10.15.6?

Yes, 10.15.6 here

Same here... Now thats strange. I do see that value in the PLIST file.