Hello GNOME and Fedora maintainers,
I’m a Fedora user and long‐time GNOME enthusiast, and I’d like to propose a set of improvements around audio device switching that would bring Fedora/GNOME in line with user expectations set by other operating systems—most notably Windows—and greatly simplify everyday workflows.
1. The Problem
Currently, when you:
- Plug in Bluetooth or wired headphones (or HDMI)
- Listen on that device
- Unplug them
GNOME/PipeWire will often revert to the system’s “default” sink (usually your laptop’s built-in speakers), not the last device you were using before that. On Windows, by contrast, the system remembers which audio device was active just prior to the one you disconnected and switches back to it automatically.
2. Why It Matters
- Seamless Experience: Audio workflows—whether music, video calls, or presentations—require you to move fluidly between outputs.
- Reduced Friction: No need to open Settings
Sound every time you unplug or re-plug devices.
- Competitive Parity: Windows users expect “plug-and-play” audio that gracefully returns to the prior output. Matching that makes Fedora/GNOME more approachable.
3. What I Did Locally
Below are all the commands I used on Fedora 42 + GNOME 48 + PipeWire to achieve both automatic switching to any newly-connected device and reverting to the penultimate sink when it’s removed:
-
Install necessary packages
sudo dnf install --allowerasing pipewire-pulseaudio wireplumber jq
-
Enable
module-switch-on-connect
(so that any new device becomes default)# Load the module immediately pactl load-module module-switch-on-connect # Make it permanent: create drop-in mkdir -p ~/.config/pipewire/pipewire-pulse.conf.d cat > ~/.config/pipewire/pipewire-pulse.conf.d/00-switch.conf <<-EOF context.modules = [ { name = libpipewire-module-switch-on-connect args = { } } ] EOF # Restart services systemctl --user restart pipewire pipewire-pulse wireplumber
-
Add “last-used” behavior via a history-stack script
-
Create
/usr/local/bin/audio-history-switch.sh
:#!/usr/bin/env bash HISTFILE="$HOME/.cache/audio-sink-history" mkdir -p "$(dirname "$HISTFILE")"; touch "$HISTFILE" push_sink(){ [[ "$(tail -n1 "$HISTFILE")" != $1 ]] && echo "$1" >> "$HISTFILE"; } pop_sink(){ sed -i '$d' "$HISTFILE"; tail -n1 "$HISTFILE"; } current=$(pactl info | awk -F': ' '/Default Sink/ {print $2}') push_sink "$current" pactl subscribe \ | grep --line-buffered "change on sink\|remove on sink" \ | while read -r _ _ _ event _; do new=$(pactl info | awk -F': ' '/Default Sink/ {print $2}') if [[ $event == *change* && $new != $current ]]; then push_sink "$new"; current="$new" elif [[ $event == *remove* ]]; then prev=$(pop_sink) if [[ -n $prev ]]; then pactl set-default-sink "$prev" pactl list short sink-inputs \ | cut -f1 \ | xargs -r -n1 -I{} pactl move-sink-input {} "$prev" current="$prev" fi fi done
-
Make it executable:
sudo chmod +x /usr/local/bin/audio-history-switch.sh
-
-
Auto-start via systemd user service
-
Create
~/.config/systemd/user/audio-history-switch.service
:[Unit] Description=Audio auto-switch to previous sink on device removal [Service] ExecStart=/usr/local/bin/audio-history-switch.sh Restart=always KillMode=process [Install] WantedBy=default.target
-
Enable & start:
systemctl --user daemon-reload systemctl --user enable --now audio-history-switch.service
-
Result:
- On connect (Bluetooth, jack, HDMI) PipeWire switches immediately to the new sink.
- On disconnect, the system reverts to exactly the sink used just before the now-removed device.
4. Suggested Upstream Implementation
-
Enable
module-switch-on-connect
by default in Fedora’s PipeWire packaging- Add the drop-in from step 2 into the default Fedora profile so new installs “just work.”
-
Add a “Remember Last Device” setting in GNOME Settings
Sound
- When enabled, maintain a small in-memory LIFO queue of sinks.
- On device removal events, pop the last-used sink and set it as default automatically.
-
Leverage existing event streams
- Use
pactl subscribe
or WirePlumber’s Lua hooks to listen forchange
andremove
events. - Implement the stack in a tiny, well-tested component (either a Lua script or C module).
- Use
-
Fallback policy
- If history is empty or setting is off, retain current behavior (new device becomes default; on removal revert to system default).
5. Benefits for Fedora/GNOME
- Polished UX: Matches user expectations from other platforms, reducing help-desk tickets.
- Accessibility: Simplifies audio switching for non-technical users.
- Minimal Maintenance: Small code additions; most logic lives in a self-contained module.
- Configurability: Let power users disable or tweak queue length.
Thank you for considering these enhancements. A small upstream change here yields a large improvement in daily usability—something I’ve already enjoyed seamlessly on my system without any side effects.
Best regards,
RaulKong898