Skip to content

Control the receiver's volume from the Mac's volume keys - #208

Open
VimalMollyn wants to merge 5 commits into
swellweb:dev-3.6.0from
VimalMollyn:feat/receiver-volume-keys-and-local-mute
Open

VimalMollyn wants to merge 5 commits into
swellweb:dev-3.6.0from
VimalMollyn:feat/receiver-volume-keys-and-local-mute

Conversation

@VimalMollyn

@VimalMollyn VimalMollyn commented Oct 12, 2026 •

Copy link
Copy Markdown

TargetBridge captures audio before the sender's own volume is applied. That means the volume keys on a MacBook never changed what the receiver played, and the same audio came out of both Macs unless you muted the MacBook by hand every time.

This PR fixes that on the sender side. No receiver changes; existing receivers work as they are.

What's new

  • A volume slider in the menu bar panel, under the brightness slider, for sessions that stream audio. It uses the existing volume packet, same as the main window. The slider was removed in 7d09729 on the assumption that the system Sound slider already controls the receiver. It doesn't: audio is captured before the Mac's volume is applied, and the sender never forwards local volume changes, so this row is the only quick control.
  • Settings > Audio > "Volume keys adjust the receiver while audio is streamed". Volume up, down and mute change the receiver's volume instead of the Mac's own, in the same 16 steps macOS uses (64 with Shift+Option). Mute remembers the level and restores it on the next press. Other media keys are untouched. This needs Accessibility permission; the settings page shows a hint and a shortcut to System Settings until it's granted.
  • Settings > Audio > "Mute this Mac's speakers while audio is streamed". Mutes the Mac's output device when streaming starts and restores it when streaming stops. Only the mute flag is touched, never the volume. A device that was already muted stays muted, and if you plug in headphones mid-session the mute moves to them.
  • The Settings window follows the system appearance (second commit). It never set a colour scheme, so on a light-mode Mac it showed dark panels under light controls. The dark main window is unchanged. Happy to split this into its own PR if you'd rather keep it separate.

Both audio settings are off by default and only do anything while a connected session has "Stream audio" on.

Testing

  • 150 unit tests pass, 10 of them new (key decoding, volume stepping, mute and restore).
  • The localization check passes, with the new strings in all five languages.
  • Tested on real hardware: Apple Silicon MacBook to an iMac over Thunderbolt. The volume keys change the iMac and leave the MacBook alone, the MacBook goes silent when streaming starts and comes back on Stop, and the menu bar slider tracks the receiver.

Notes

  • There's no volume HUD on the sender when the keys are intercepted, because the system never sees the press. The feedback is the receiver's level changing.
  • Mute works on the level alone because the wire protocol only carries a level. A muted field could be added later without breaking older receivers.
  • Where things live: TBReceiverVolumeKeys.swift (key decoding and stepping, unit tested), TBVolumeKeyBridge.swift (the event tap), TBLocalOutputMuter.swift (CoreAudio mute), plus wiring in the sender manager, the menu bar controller, the settings view, the language files and the docs.

🤖 Generated with Claude Code

VimalMollyn and others added 2 commits October 12, 2026 03:59
TargetBridge captures audio before the sender's own volume is applied. That
means the volume keys on a MacBook never changed what the receiver played,
and the same audio came out of both Macs unless you muted the MacBook by
hand every time.

This adds:

- A volume slider in the menu bar panel, under the brightness slider.
- Settings > Audio > "Volume keys adjust the receiver while audio is
  streamed". Volume up, down and mute change the receiver's volume instead
  of the Mac's own. Mute remembers the level and restores it on the next
  press. Needs Accessibility permission; the settings page shows a hint and
  a shortcut to System Settings until it's granted.
- Settings > Audio > "Mute this Mac's speakers while audio is streamed".
  Mutes the Mac's output device when streaming starts and restores it when
  streaming stops. If you plug in headphones mid-session, they're muted too.

Both settings are off by default, and nothing changes on the receiver side.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The Settings window never set a colour scheme, so on a Mac in light mode its
controls were light while the background and cards stayed dark.

The background now matches the current appearance, and the shared card style
tints with the primary colour instead of white. The dark main window looks
exactly as before, and a light window gets soft grey cards.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@VimalMollyn
VimalMollyn force-pushed the feat/receiver-volume-keys-and-local-mute branch from 2a3f9b3 to ff6c09c Compare October 12, 2026 07:59
@VimalMollyn VimalMollyn changed the title feat(sender): volume keys drive the receiver, auto-mute local speakers, menu-bar volume slider Control the receiver's volume from the Mac's volume keys Oct 12, 2026
@swellweb
swellweb changed the base branch from main to dev-3.6.0 October 12, 2026 11:02
@swellweb

Copy link
Copy Markdown
Owner

Thank you for the contribution and the real-hardware testing. I am keeping this out of the small 3.6.1 maintenance candidate because it adds new audio behavior and currently conflicts with the development base. I would like to review the volume-key/local-mute work separately from the unrelated window-appearance change, then validate mute restoration, output-device changes, multiple sessions and both input roles before merging. No audio regression is being marked fixed by this PR yet.

@VimalMollyn

Copy link
Copy Markdown
Author

No problem, happy to contribute for an app I'm using almost everyday!

swellweb added a commit that referenced this pull request Nov 12, 2026
Reconcile already-integrated PR heads without runtime changes, preserve rc.2 hardening, and add the appearance-only fix from #208 with rendering regressions. Fresh 200 Sender tests, universal Release build, Receiver/parser tests and focused guards pass. Stable-release gates remain documented; no release or installed apps are changed. Fixes #235. Fixes #224.
@swellweb

Copy link
Copy Markdown
Owner

I have taken only the standalone Settings appearance commit ff6c09c into the 3.6 maintenance closeout (#236, now integrated into main via #218) to resolve #235. The original author and co-author attribution are preserved, and I added four rendering/contrast regressions. I have not merged the volume-key interception or local-output mute changes, so I am keeping this PR open for that separate audio review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants