I got absolutely fed up with a bug in Linux audio where plugging in or unplugging any audio output device resets every single microphone's input gain to 100%. I have lost count of how many times I ear-raped my friends in a Discord call because my mic suddenly started clipping at full blast just because I connected my Bluetooth headphones or plugged in a USB DAC.
This happens on PipeWire/WirePlumber (the default audio stack on Arch and most other distros) when a device hotplug triggers a route re-evaluation and the default source volume of 1.0 (100%) gets applied before the saved state can be restored. Sometimes the restoration just doesn't happen in time and you're left screaming into your friends' ears.
Two layers:
-
WirePlumber config - overrides the dangerous
device.routes.default-source-volumefrom 1.0 to 0.25. Even if a hotplug reset occurs, your mic defaults to 25% instead of 100%. -
Polling guard daemon - a systemd user service that checks all input sources every second. If any source jumps to 100%, it's instantly reverted to the last known safe volume. Volumes are persisted to disk so they survive reboots.
- PipeWire + WirePlumber 0.5+
pactl(frompipewire-pulseorpulseaudio-utils)
cd ~/input-gain-fix
chmod +x install.sh
./install.sh install
systemctl --user restart wireplumber./install.sh uninstall./install.sh status[16:15:13] Guard: restoring alsa_input.pci... from 100% -> 40%
The guard remembers the last volume you set that wasn't 100%. If a source suddenly hits 100% it restores it immediately. If you actually do want 100%, just set it 3 times and the guard will stop fighting you.