Fix mute on Aggregate Devices (use CoreAudio mute property)#27
Open
super-cache-money wants to merge 1 commit into
Open
Fix mute on Aggregate Devices (use CoreAudio mute property)#27super-cache-money wants to merge 1 commit into
super-cache-money wants to merge 1 commit into
Conversation
AppleScript `set volume input volume 0` is a no-op on Aggregate Devices, so the menu bar icon would briefly flash red and then revert to unmuted within a second (the watchdog timer reads the still-high volume back and forces the UI to "unmuted"). Replace the mute path with CoreAudio: resolve the default input device, and for an aggregate, dispatch `kAudioDevicePropertyMute` (and `VolumeScalar` for the slider) to each input-bearing sub-device. Master element first, then per-channel fallback; if the device exposes no writable mute property, fall back to driving volume to 0. Also update the 1-second watchdog and `getCurrentVolume` to read the real CoreAudio mute/volume state instead of the AppleScript value (which on aggregates is often a stale 100).
Owner
|
Hey @super-cache-money, thanks for your PR but I already have more or less the same changes (plus a lot more) on my local setup. It will be part of the v2. |
Author
|
OK, really, really looking forward to your new version!
Warmly,
Arjun Khoosal
+27 74 061 9155 <https://wa.me/27740619155>
about me <https://arjun.md?utm_source=email-sig>
…On Wed, Jun 17, 2026 at 9:40 AM Sascha Petrik ***@***.***> wrote:
*satrik* left a comment (satrik/toggleMute#27)
<#27 (comment)>
Hey @super-cache-money <https://github.com/super-cache-money>, thanks for
your PR but I already have more or less the same changes (plus a lot more)
on my local setup. It will be part of the v2.
I will double check your code and compare it with my code to make sure to
not forget any feature you wanted to bring in.
—
Reply to this email directly, view it on GitHub
<#27?email_source=notifications&email_token=AALFG2LTFC6ORICAZMLT3ED5AJDP7A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINZSG4ZTEOJSGQZ2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4727329243>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALFG2IEPRJHR6RVLGRZJGL5AJDP7AVCNFSNUABFKJSXA33TNF2G64TZHMZTSMZUGMZTIMBTHNEXG43VMU5TINJRGYZDCNRVHAZ2C5QC>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Contributor
|
Could you create a (draft) PR? @satrik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pressing the toggleMute hotkey while an Aggregate Device is the default input doesn't actually mute the mic. The menu bar icon briefly flashes red, then reverts to unmuted ~1 second later. This PR fixes that.
Why this matters
A common macOS workaround for the auto-switching-input-to-Bluetooth-headphones annoyance is to create an Aggregate Device that wraps your built-in mic, and set that as the system input — so the system never switches away from your real mic when AirPods/headphones connect. See e.g. this r/MacOS comment which is the recipe a lot of people land on. Anyone using that workaround currently can't use toggleMute.
Root cause
Two things conspire:
set volume input volume 0is a no-op on Aggregate Devices. Aggregates don't expose a writable master volume — they delegate to their sub-devices — so the AppleScript silently does nothing. A regular USB/built-in mic implements the property directly, which is why those work.AppDelegate.runTimedCodeoverrides the UI. It reads input volume via the same broken AppleScript path; for aggregates the read returns a stale ~100, so it flips the icon back to "unmuted" right after you tried to mute.Fix
New
AudioInputController(Support/) that drives mute and volume via CoreAudio:kAudioDevicePropertyMute/kAudioDevicePropertyVolumeScalarto each input-bearing sub-device.TouchBarController.toggleMuteStateHardandsetNewVolumenow go throughAudioInputControllerinstead of AppleScript.AppDelegate.runTimedCodeandMainController.getCurrentVolumeread real mute/volume state via CoreAudio. If the state can't be read, the watchdog leaves the UI alone (no more flip-back).No change to the behaviour with non-aggregate devices — those paths still work as before.
Tested
Built and ran locally on macOS (Apple Silicon), with an Aggregate Device set as default input. Confirmed:
Test plan