Route volume media keys to the default audio output device - #19
Merged
Conversation
Volume/mute media keys followed the brightness MediaKeyTargetMode (under cursor / main / built-in). If that display was a DDC-audio external, the keys drove the monitor's DDC volume even when system sound was on the MacBook speakers, AirPods, a USB DAC, etc. Volume/mute now follow the system's DEFAULT AUDIO OUTPUT DEVICE: - Not a display (speakers / headphones / AirPods / USB DAC / aggregate) -> pass through so macOS adjusts it natively with its own HUD. - An external monitor's HDMI/DP audio, active and DDC-volume-capable -> drive that monitor's DDC volume/mute, even if the cursor/main display is elsewhere. - Inactive / not volume-capable / unmatchable -> pass through (fail safe). Brightness keys are unchanged (still follow MediaKeyTargetMode). - AudioOutputInfo (macOS glue): reads the CoreAudio default output device name + transport per keypress. - AudioOutputDisplayMatcher (pure TopologyCore, no CoreAudio): maps device name/transport to a display record; case-insensitive exact->contains match, single-active-external fallback, ambiguous->nil. - MediaKeyTargetPolicy.target gains an audioTarget: parameter; the volume branch ignores mode/cursor and routes only to that display. - SettingsView copy: picker now labeled for brightness keys; adds "Volume keys follow the current sound output device." make test green (+12 matcher tests, policy tests migrated); both app schemes build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5de1c4a626
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- AudioOutputDisplayMatcher: an exact name match now requires exactly
one hit. Two identical monitors share a product name and CoreAudio
routes to only one of them, so two exact hits are ambiguous -> nil
(fail safe), matching the contains branch's behavior.
- AppModel: match audio devices against the OS/hardware display name,
not the user alias. displayName(for:) returns the alias first, so an
aliased monitor ("Desk") never matched its CoreAudio device name
("Dell U2720Q") and volume keys wrongly passed through. Factored out
osDisplayName(for:) (localized name, no alias) for the matcher.
- Test for the two-identical-monitors exact-name case.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
aquitaine
added a commit
that referenced
this pull request
Jul 19, 2026
Add menu-bar popover + settings screenshots as the hero image pair, replacing the placeholder comment. Update the media-keys feature bullet: volume keys now follow the current sound output device (PR #19), not the brightness target mode. Co-authored-by: Claude <noreply@anthropic.com>
Merged
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.
Problem
The media-key interception (Settings → "Use the brightness & volume keys to control displays") routed the hardware volume/mute keys to whichever display the brightness target mode resolved (under cursor / main / built-in). If that display was a DDC-audio-capable external, the keys changed the monitor's DDC volume even when system sound was playing through the MacBook speakers, AirPods, a USB DAC, etc.
Real scenario: built-in display off, external monitor is main, default audio output = MacBook speakers → volume keys wrongly drove the monitor's DDC volume while sound kept coming from the speakers.
Fix
Volume/mute keys now follow the system default audio output device, decoupled from the brightness target mode:
Brightness keys are unchanged — they still follow
MediaKeyTargetMode.Implementation (pure-core / macOS-glue split)
AudioOutputInfo.swift(new, macOS glue) — reads the CoreAudio default output device name + transport type per keypress (single property reads, microseconds; no listener/cache).AudioOutputMatch.swift(new, pure TopologyCore, no CoreAudio/IOKit) —AudioOutputTransportenum +AudioOutputDisplayMatcher: transport must be hdmi/displayPort else nil; case-insensitive exact→contains name match to a display; single-active-external fallback; ambiguous → nil.MediaKey.swift—MediaKeyTargetPolicy.targetgains anaudioTarget:parameter; the volume branch ignores mode/cursor and routes only to that display when it's active + volume-capable. Updated doc comments on the policy andisVolume.AppModel.swift—handleMediaKeyresolvesaudioTarget(via newaudioOutputDisplayID(), reusingdisplayName(for:)) for volume actions only; mute'spreMuteVolumelogic andvolumeCapableDisplayIDs()fail-open behavior unchanged.SettingsView.swift— picker relabeled "Brightness keys control the…", added "Volume keys follow the current sound output device." No new user setting.Tests / verification
make testgreen — added 12 matcher tests (name exact/prefix/case-insensitive, wrong transport, single-external fallback, two-external ambiguity); migrated policy tests to the new signature (volume routes toaudioTargetregardless of mode; passes through when nil/inactive/not-capable; brightness unchanged).OpenDisplayandOpenDisplay-PublicAPIOnlyschemes build (ranmake xcode— two new source files).Manual live checks