Skip to content

fix(audio): volume keys move the default sink instead of the active call stream - #14806

Closed
dmedina13-fl wants to merge 1 commit into
omacom:quattrofrom
dmedina13-fl:audio-follow-active-stream
Closed

dmedina13-fl wants to merge 1 commit into
omacom:quattrofrom
dmedina13-fl:audio-follow-active-stream

Conversation

@dmedina13-fl

@dmedina13-fl dmedina13-fl commented Oct 10, 2026 •

Copy link
Copy Markdown

Problem

During a call, the volume keys and a headset volume knob (which sends the same XF86Audio* events) control the laptop's default sink instead of the call. The headset is a separate, non-default sink, so pressing volume up raises the speakers while the call is playing into the headset.

What

The volume keys follow the stream that is actually playing, instead of always the default sink.

Why

Linux routes the volume keys to the default sink, and PipeWire keeps the call on its own sink, so the keys act on the wrong device for the entire call. This makes them act on the currently playing stream, matching what users expect mid-call.

How

  • omarchy-audio-output-sink --active resolves the sink an uncorked stream is playing into when that is not the default sink, preferring a communication stream (media.role phone/communication, PipeWire's canonical VOIP role) so a meeting outranks background playback when several streams play at once. Falls back to the default sink otherwise.
  • omarchy-audio-output-volume --follow-active steps that sink instead of the default.
  • Every volume-key path passes the flag: the ALT + XF86Audio* precise bindings, the { audio = ... } helpers fallback, and the shell's runShortcut fallback.
  • The shell's in-process fast path (omarchy.media handleVolumeKey) now defers to the script when the active sink differs from the default. The shell cannot see which sink a stream is linked to, so the active sink is resolved in a process (omarchy-audio-output-sink --active), refreshed on default-sink change, on a 5s timer, and on each press. The common case — nothing playing on a second output — still steps the default sink in-process with no process spawned.

Testing

  • New test/shell.d/audio-output-active-test.sh covers the resolver: idle → default, uncorked stream wins, default/monitor/corked skipped, call outranks music, explicit sink-name overrides --active.
  • Updated test/shell.d/media-test.sh (shell deferral + --follow-active fallback) and test/shell.d/shell-shortcuts-test.sh (fallback command).
  • ./test/cli passes (metadata lint for the two changed bin commands).

Related work

The shell deferral is a deliberate middle ground: it keeps the zero-process fast path introduced in #13424 for the default-sink case, and only spends a resolver process when a non-default stream is active (or to keep the resolution fresh).

Linux routes the volume keys to the default sink, so during a call the
headset is a separate, non-default sink and the keys (and a headset
volume knob sending the same XF86 events) move the laptop speakers
instead of the call.

Teach omarchy-audio-output-sink an --active mode that resolves the sink
an uncorked stream is playing into when that is not the default sink,
preferring a communication stream (media.role phone/communication).
omarchy-audio-output-volume gains --follow-active, and every volume-key
path (the ALT precise bindings, the helpers fallback, and the shell's
runShortcut fallback) passes it. The shell's in-process fast path now
defers to the script when the active sink differs from the default,
resolved through omarchy-audio-output-sink --active, so the common
default-sink case still steps the volume without spawning a process.
@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[Medium impact] Routes volume keys to follow active audio streams.

Fix the stale-output press and default-output call preference before merging.

Findings

  1. P1 First press changes speakers ▶
  2. P1 Music wins over calls ▶

Summary

Adds --active output selection and routes volume-key fallbacks through --follow-active. The shell caches the selected output and defers to the script when it differs from the default.

  • Volume keys follow the output with active playback.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Key[Volume key] --> Cache{Cached output differs from default?}
  Cache -->|Yes| Script[Run volume command with --follow-active]
  Cache -->|No| Refresh[Start refresh without waiting]
  Refresh --> Default[Change default output immediately]
  Script --> Resolve[Resolve playing outputs, calls first]
  Resolve --> Skip[Skip every default-output candidate]
  Skip --> Change[Change first remaining output]
Loading

Reviews (1) · Last reviewed commit: "Route volume keys to the stream that is ..." · Reviewed by Greptile

Comment on lines +514 to +516
if (activeSinkName && activeSinkName !== String(defaultSink.name)) return false

refreshActiveSink()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 First press changes speakers

When a headset call starts between polls, activeSinkName still names the default output. handleVolumeKey checks that old value, starts a refresh, then changes the speakers before the result arrives. It returns true, so the script never handles that press. Resolve the output before applying the action, or defer to the script while the cached answer may be stale.

name="$(pactl -f json list sinks 2>/dev/null |
jq -r --argjson i "$idx" '.[] | select(.index == $i) | .name' 2>/dev/null)"
[[ -n $name ]] || continue
[[ $name == "$default_sink" ]] && continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Music wins over calls

A call on the default output loses to background music on another output. The resolver puts the call first, but this unconditional continue discards it because it uses the default output. The loop then returns the music output, so volume and mute keys control music rather than the call. Keep the preferred call output even when it is the default, and add this mixed-output case to the tests.

@dmedina13-fl dmedina13-fl changed the title Route volume keys to the stream that is actually playing fix(audio): volume keys move the default sink instead of the active call stream Oct 10, 2026
@b2amedina

Copy link
Copy Markdown

Superseded by #14813 — reopened under the correct account (b2amedina).

1 similar comment
@dmedina13-fl

Copy link
Copy Markdown
Author

Superseded by #14813 — reopened under the correct account (b2amedina).

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