Skip to content

feat(sender): add brightness & volume sliders to the menu bar - #143

Closed
aalpgiray wants to merge 1 commit into
swellweb:mainfrom
aalpgiray:feat/menubar-brightness-volume-sliders
Closed

aalpgiray wants to merge 1 commit into
swellweb:mainfrom
aalpgiray:feat/menubar-brightness-volume-sliders

Conversation

@aalpgiray

@aalpgiray aalpgiray commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor
image

What

Adds Brightness and Volume sliders directly to the menu-bar status menu — one per connected session — so the receiver's real brightness/volume can be adjusted without opening the main window.

Why

The receiver already applies real brightness (DisplayServicesSetBrightness) and volume, but today they're only reachable from the main window's session card. Surfacing them in the menu bar makes them a one-click adjustment — the same reliable, native-feeling pattern that apps like BetterDisplay / MonitorControl use (their own menu sliders), with none of the media-key / event-tap fragility.

How

  • Each slider is a custom-view NSMenuItem (SF Symbol icon + NSSlider) whose value is pushed live to session.brightness / session.volume, which already forward to the receiver. No event taps, no cursor/keyboard routing — it behaves identically regardless of external keyboards, Universal Control, etc.
  • Sliders appear only for connected sessions; the volume slider only when audio is enabled.
  • Also tidies the status menu: the verbose interface/IP line and per-session status lines move into a Connection info submenu, so the default menu is status summary → sliders → actions.
  • Localized (en/it/de/zh).

Contained entirely in TBDisplaySenderStatusItemController.swift; no new files, no project changes.

Testing

  • xcodebuild test (TBDisplaySender scheme): 72/72 pass.
  • Verified end-to-end on a real receiver: dragging the menu-bar Brightness slider changes the receiver's real backlight; Volume changes the receiver's system volume.

🤖 Generated with Claude Code

Surfaces per-session Brightness and Volume sliders directly in the menu
bar status menu, so the receiver's real brightness/volume can be adjusted
without opening the main window. Each slider pushes its value live to the
existing session.brightness / session.volume path (already forwarded to
the receiver), so it works reliably regardless of keyboard or input
routing — no event taps, no cursor/media-key handling.

Sliders appear only for connected sessions; the volume slider only when
audio is enabled. Also tidies the menu: the verbose interface/IP and
per-session status lines move into a "Connection info" submenu, keeping
the default menu focused on the status summary, sliders, and actions.
Localized en/it/de/zh.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@aalpgiray

Copy link
Copy Markdown
Contributor Author

After implementing audio driver for natural audio bridge

file-703bab450402543cfed66648509efd17

I made this display only.

file-22d12e925338e433afa6218f6e0d98d8

Will update this pr soon.

aalpgiray added a commit to aalpgiray/targetBridge that referenced this pull request Jul 29, 2026
Adds Control-Center-style toggles to the menu bar for the receiver's Night Shift
and True Tone, and drops the volume slider — with an audio device selected,
macOS's own Sound slider already drives the receiver's hardware volume, so a
second control here can only disagree with the system one.

Two-way: changing either on the receiver itself (Control Centre, System
Settings) propagates back, so the toggles never show a stale state.

## Notes

Both live in the private CoreBrightness framework, reached by dlopen and the
Objective-C runtime — the same approach this app already uses for DisplayServices
brightness — so a missing class or renamed selector degrades to "unsupported"
rather than breaking the build or crashing on a future macOS. The receiver
advertises supportsNightShift / supportsTrueTone in its profile and the toggles
appear only when it does.

CBTrueToneClient exposes both activate/deactivate and setEnabled:. The first
pair looks like the on/off switch and is not — measured against the live
framework, after deactivate the panel is unchanged and `enabled` still reports 1.
They activate the client *session*. setEnabled: is the real switch, with
activate/deactivate kept only as a fallback.

One deliberately fragile spot: CBBlueLightClient has no `enabled` getter, only
getBlueLightStatus:, which fills a private struct. It is read into an oversized
zeroed buffer so a larger struct on a future macOS cannot overflow, and a
changed layout misreports the toggle rather than crashing.

## Panel styling

The panel was ~240 pt against Control Center's ~340 and the symbols were wrong.
Width now comes from one constant; note the row width and the visible panel
width differ, because a menu draws chrome around the item.

Symbols were checked by rendering every plausible SF Symbol and comparing with
Control Center rather than picking by name. Apple's family is half-circle ->
half-sun -> full-sun for Dark Mode, Night Shift and True Tone, so Night Shift is
a *sun with a dark half*, not a moon. True Tone's real glyph has lines through
the disc and no SF Symbol does — Control Center appears to use a private asset —
so sun.max.fill is the closest public match.

The slider track stays grey, and the comment now records why: trackFillColor is
set and menus ignore it, and overriding NSSliderCell.drawBar produces the accent
fill but opts the cell out of AppKit's modern rendering, costing the knob its
pressed-state translucency. A control that feels wrong beats one that looks
plain.

Accessibility: the slider carries its name (previously only its decorative
glyphs did), the toggles use the checkbox role with a value that follows the
state, and the captions are out of the accessibility tree rather than read as
extra elements.

Includes swellweb#143, which this builds on, rebased onto current main — that also
required filling in the French labels it predates.

Co-Authored-By: Claude Opus 5 <[email protected]>
@aalpgiray aalpgiray closed this Jul 29, 2026
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.

1 participant