clawdie-iso/live/operator-session/clawdie-live-audio
Sam & Claude 6bade5d04e Merge xfce-operator-usb: AMD ASUS hardware lane + XFCE panel polish (Sam & Claude)
Consolidates the operator-USB work into main now that the AMD ASUS hardware-evidence collection is closed and Codex is parked. Brings the live-session hardware lane (XInput/libinput touchpad guard, internal audio + resolver bootstrap, hw-report with gated public upload, operator-USB branding) and the config-only XFCE panel polish (Pass 1 + Pass 2: branded Whisker PNG, xkb text mode, panel 40px, systray square-icons).

Conflict: doc/LLM-PROVIDER-HARNESS.md was evolved on both sides. Resolved as a union with no content lost — the xfce-side harness/provider/fabric restructure is the base, and main's two unique blocks (Verifying Key Cleanup flow, the 2D Platform x Harness matrix + populate/add procedures) are preserved. The doc owner may later dedupe the overlap between the two 1D matrices and the 2D matrix.

Verification debt stays explicit and open (not closed by this merge): XFCE visual-polish confirmation and the next rebuilt-image hardware retest, per doc/XFCE-PANEL-BUGS-HANDOFF.md and PLAN-OPERATOR-USB-NEXT.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-04 20:04:23 +02:00

73 lines
2 KiB
Bash

#!/bin/sh
# Clawdie operator USB audio default selector.
#
# Laptops with HDMI attached can expose the GPU HDMI codec as pcm0, making
# FreeBSD choose HDMI as hw.snd.default_unit even when the internal speaker is
# available. Prefer an internal analog-style playback device when one exists;
# leave the system untouched if no better candidate can be identified.
# PROVIDE: clawdie_live_audio
# REQUIRE: FILESYSTEMS kld
# BEFORE: sddm
# KEYWORD: nojail
. /etc/rc.subr
name="clawdie_live_audio"
rcvar="${name}_enable"
start_cmd="${name}_start"
stop_cmd=":"
clawdie_live_audio_pick_unit() {
[ -r /dev/sndstat ] || return 1
awk '
/^pcm[0-9]+:/ {
unit = $1
sub(/^pcm/, "", unit)
sub(/:$/, "", unit)
line = tolower($0)
score = 0
if (line ~ /hdmi|displayport/) score -= 100
if (line ~ /realtek|analog|speaker|headphone|alc/) score += 80
if (line ~ /play/) score += 10
if (line ~ /default/) score += 1
if (best == "" || score > best_score) {
best = unit
best_score = score
best_line = $0
}
}
END {
if (best != "" && best_score > -100) {
print best
}
}
' /dev/sndstat
}
clawdie_live_audio_start() {
_unit="$(clawdie_live_audio_pick_unit 2>/dev/null || true)"
if [ -z "${_unit:-}" ]; then
echo "${name}: no non-HDMI playback device selected"
return 0
fi
_current="$(sysctl -n hw.snd.default_unit 2>/dev/null || true)"
if [ "${_current}" = "${_unit}" ]; then
echo "${name}: hw.snd.default_unit already ${_unit}"
return 0
fi
if sysctl "hw.snd.default_unit=${_unit}" >/dev/null 2>&1; then
echo "${name}: set hw.snd.default_unit=${_unit}"
else
echo "${name}: failed to set hw.snd.default_unit=${_unit}" >&2
return 1
fi
}
load_rc_config "$name"
: "${clawdie_live_audio_enable:=YES}"
run_rc_command "$1"