Skip to content

feat: add audio device switcher to bar - #131

Open
flathead wants to merge 3 commits into
Axenide:devfrom
flathead:feature/audio-device-switcher
Open

feat: add audio device switcher to bar#131
flathead wants to merge 3 commits into
Axenide:devfrom
flathead:feature/audio-device-switcher

Conversation

@flathead

@flathead flathead commented Mar 25, 2026

Copy link
Copy Markdown

Adds a bar button for switching audio output/input devices with a popup selector.

What was added

New file

modules/bar/AudioDeviceSwitcher.qml -- bar button that:

  • Shows a dynamic icon based on the current default sink type
  • Opens a popup with Output and Input sections listing available devices
  • Clicking a device sets it as the default sink/source
  • Supports headset battery display (ArctisManager D-Bus) when a headset-type sink is active
  • Filters out devices listed in the exclusion config

Device type detection

Icons are assigned dynamically from PipeWire node properties, not hardcoded names:

Type Icon Detection
HDMI/DP speakerHigh device.profile.name contains hdmi or displayport
Headphones/USB headphones device.bus is usb or bluetooth, or headset/headphone profile
Audio processor faders node.virtual=true or application.id matches easyeffects, carla, jamesdsp, pulseeffects
Virtual routed sink inherits from driver node.driver-id traced to real device, classified by its properties
Speakers speaker PCI analog, fallback
Microphone mic any source

Settings integration

config/Config.qml -- added showAudioDeviceSwitcher (bool, default true) and excludedAudioSinks (string list, default empty) to the bar adapter.

modules/widgets/dashboard/controls/ShellPanel.qml -- added to Bar section:

  • Toggle: "Show Audio Device Switcher"
  • Chip selector: "Hidden Audio Devices" with clickable chips for all current audio devices. Click to exclude, click again to restore. Follows the same pattern as the Screen selector.

modules/widgets/dashboard/controls/SettingsIndex.qml -- added search entries for "Audio Device Switcher" and "Excluded Audio Sinks".

Modified files

modules/bar/BarContent.qml -- added AudioDeviceSwitcher via Loader in both horizontal and vertical layouts, between ControlsButton and BatteryIndicator. Visibility controlled by Config.bar.showAudioDeviceSwitcher.

Demo

1
2026-04-01T21-22-02-413Z.mp4

Install as a mod

Requires the native manager from PR #230. Paste the package link into Settings → Mods → Package source:

https://github.com/flathead/ambxst-mods/tree/main/packages/audio-device-switcher

The package needs community.i18n (PR #134) for its popup and Settings strings. The details pane marks that requirement as missing, disabled, or ready, and Install required mods fetches i18n, enables it first, and leaves this package for you to enable. The same steps from the CLI:

ambxst mods install https://github.com/flathead/ambxst-mod-i18n.git
ambxst mods enable community.i18n
ambxst mods install https://github.com/flathead/ambxst-mods/tree/main/packages/audio-device-switcher
ambxst mods enable community.audio-device-switcher
ambxst reload

The packaged version targets the current dev base and keeps PipeWire device nodes bound until an asynchronous switch has been dispatched. This includes the follow-up fix for selections that occasionally appeared to do nothing when the popup closed.

Merge into Ambxst core

For core review, take this PR's branch: the feature as ordinary Ambxst source on dev.

The package patch is a separate artifact. It targets a tree that already carries the mod manager from PR #230 and the community.i18n package, because that is the only tree a mod can be installed on. To reproduce exactly what the manager composes:

git remote add flathead https://github.com/flathead/Ambxst.git
git fetch flathead feature/mod-manager
git switch -c mods/audio-device-switcher flathead/feature/mod-manager
git apply --3way ambxst-mod-i18n/patches/feature.patch
git apply --3way ambxst-mods/packages/audio-device-switcher/patches/feature.patch
go test ./...
go vet ./...

It adds AudioDeviceSwitcher.qml, registers it in both bar orientations, and adds its Config, Settings, exclusion list, and search-index entries. If i18n is not part of the core plan, this PR's branch carries the same feature with plain English strings. No mod-specific runtime API is involved after application; this is the same source layout intended for core.

Package parity

The package in flathead/ambxst-mods and this branch now carry the same feature code. AudioDeviceSwitcher.qml differs in exactly two lines, where the package calls the translator and this branch uses plain English; the PipeWire node-binding fix is present in both. The Config, bar, and Settings files differ only in their registration lines, because the package is generated on a tree that also carries the mod manager and community.i18n.

Add a bar button for switching audio output/input devices with a popup
selector. Device type icons (headphones, speakers, HDMI, mic) are
determined dynamically from PipeWire node properties instead of
hardcoded name matching.

Includes settings integration:
- Toggle to show/hide the switcher
- Comma-separated exclusion list to hide unwanted sinks from the popup

New files:
- modules/bar/AudioDeviceSwitcher.qml

Modified files:
- modules/bar/BarContent.qml
- config/Config.qml
- modules/widgets/dashboard/controls/ShellPanel.qml
- modules/widgets/dashboard/controls/SettingsIndex.qml
@Axenide

Axenide commented Mar 28, 2026

Copy link
Copy Markdown
Owner

Nice, please add some screenshots. :)

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