audio: baseline the internal speaker at full volume on boot and hotplug

PortAudio has no volume control, so a muted ALSA Master silences the voice
gateway's cue and replies, and the mixer resets whenever a sound device is
added/removed. scripts/audio-baseline.sh sets the analog speaker (found by its
'Speaker' control, so a shifting card index does not matter) to 100% unmuted;
scripts/audio-baseline-watch.sh re-applies it on every sound udev event. Both
are driven by systemd user services (audio-baseline.service / -watch.service)
so they run at startup and on hotplug.
This commit is contained in:
gabby committed 2026-10-09 08:19:39 +00:00
1 parent ec39a990e4
commit dcfe5e5fec
2 files changed
+46

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
# Re-apply the audio baseline whenever a sound device is added, changed, or
# removed, so the internal speaker stays at full volume and unmuted (the
# baseline) after a USB mic, HDMI, or headset is plugged or unplugged.
#
# `udevadm monitor` is readable without root, so this runs as a long-lived
# systemd user service (see `audio-baseline.service`); each sound event
# triggers one idempotent apply of `audio-baseline.sh`.
set -u
BASELINE="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)/audio-baseline.sh"
stdbuf -oL udevadm monitor --udev --subsystem-match=sound 2>/dev/null \
| while IFS= read -r line; do
# Event lines look like `UDEV [1696.123] add /devices/... (sound)`;
# the `[` distinguishes them from the 3-line startup banner.
case "$line" in
UDEV*\[*) "$BASELINE" ;;
esac
done