From 9144743409a90e1aee1aa2ed6e0ed556aa31e4b8 Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Sat, 18 Apr 2026 03:49:34 +0200 Subject: [PATCH 1/2] fix(audio): correct audio volume initialization and pipewire setup - Add pulseaudio-utils dependency package - Add wireplumber config directory creation - Rewrite audio setup scripts with proper sound card waiting - Replace broken PipeWire running check with hardware detection - Add safe control setter that skips missing audio controls - Set default PipeWire audio sink volume to 100% - Include new pipewire configs for volume and ACP disable - Apply fixes across all audio driver stage variants --- .../03-install-pipewire-audio/01-packages | 1 + .../03-install-pipewire-audio/02-run.sh | 6 +- .../files/50-volume.conf | 14 +++ .../files/51-disable-acp.conf | 14 +++ .../files/configure_audio.sh | 89 +++++++++++-------- .../files/configure_audio.sh | 89 +++++++++++-------- .../files/configure_audio.sh | 89 +++++++++++-------- 7 files changed, 189 insertions(+), 113 deletions(-) create mode 100644 01-stage-picompose/03-install-pipewire-audio/files/50-volume.conf create mode 100644 01-stage-picompose/03-install-pipewire-audio/files/51-disable-acp.conf diff --git a/01-stage-picompose/03-install-pipewire-audio/01-packages b/01-stage-picompose/03-install-pipewire-audio/01-packages index 045feb9..fc027b6 100644 --- a/01-stage-picompose/03-install-pipewire-audio/01-packages +++ b/01-stage-picompose/03-install-pipewire-audio/01-packages @@ -3,4 +3,5 @@ wireplumber pipewire-audio-client-libraries libspa-0.2-bluetooth pipewire-audio +pulseaudio-utils pipewire-pulse \ No newline at end of file diff --git a/01-stage-picompose/03-install-pipewire-audio/02-run.sh b/01-stage-picompose/03-install-pipewire-audio/02-run.sh index 5eb0172..a4e4b3d 100755 --- a/01-stage-picompose/03-install-pipewire-audio/02-run.sh +++ b/01-stage-picompose/03-install-pipewire-audio/02-run.sh @@ -1,10 +1,12 @@ #!/bin/bash -e -# Create the pipewire directory +# Create directorys mkdir -p "${ROOTFS_DIR}/etc/pipewire" mkdir -p "${ROOTFS_DIR}/etc/pipewire.conf.d" +mkdir -p "${ROOTFS_DIR}/etc/wireplumber/wireplumber.conf.d" -# Copy pipewire config +# Copy configs +install -v -m 644 files/linux-voice-assistant.conf "${ROOTFS_DIR}/etc/pipewire.conf.d/linux-voice-assistant.conf" install -v -m 644 files/linux-voice-assistant.conf "${ROOTFS_DIR}/etc/pipewire.conf.d/linux-voice-assistant.conf" on_chroot << EOF diff --git a/01-stage-picompose/03-install-pipewire-audio/files/50-volume.conf b/01-stage-picompose/03-install-pipewire-audio/files/50-volume.conf new file mode 100644 index 0000000..806ce67 --- /dev/null +++ b/01-stage-picompose/03-install-pipewire-audio/files/50-volume.conf @@ -0,0 +1,14 @@ +monitor.alsa.rules = [ + { + matches = [ + { + node.name = "~alsa_output.*" + } + ] + actions = { + update-props = { + audio.volume = 1.0 + } + } + } +] diff --git a/01-stage-picompose/03-install-pipewire-audio/files/51-disable-acp.conf b/01-stage-picompose/03-install-pipewire-audio/files/51-disable-acp.conf new file mode 100644 index 0000000..98ce8bd --- /dev/null +++ b/01-stage-picompose/03-install-pipewire-audio/files/51-disable-acp.conf @@ -0,0 +1,14 @@ +monitor.alsa.rules = [ + { + matches = [ + { + device.name = "~alsa_card.*" + } + ] + actions = { + update-props = { + api.alsa.use-acp = false + } + } + } +] diff --git a/02-stage-audiodriver-2michat-v1/02-set-audio-volume/files/configure_audio.sh b/02-stage-audiodriver-2michat-v1/02-set-audio-volume/files/configure_audio.sh index 871dbdf..9c49b4b 100644 --- a/02-stage-audiodriver-2michat-v1/02-set-audio-volume/files/configure_audio.sh +++ b/02-stage-audiodriver-2michat-v1/02-set-audio-volume/files/configure_audio.sh @@ -1,51 +1,66 @@ #!/bin/bash +set -u -check_pipewire() { - local MAX_TRIES=30 - local SLEEP_SEC=1 - local COUNT=0 +wait_for_card_and_control() { + local card="$1" + local control="$2" + local max_tries=30 + local sleep_sec=1 + local count=0 - while [ $COUNT -lt $MAX_TRIES ]; do - COUNT=$((COUNT + 1)) + while [ "$count" -lt "$max_tries" ]; do + count=$((count + 1)) - # Check if XDG_RUNTIME_DIR is set - if [ -z "$XDG_RUNTIME_DIR" ]; then - echo "❌ XDG_RUNTIME_DIR is not set" - return 1 + if amixer -c "$card" info >/dev/null 2>&1; then + if amixer -c "$card" scontrols | grep -Fq "'$control'"; then + echo "Card $card with control '$control' is ready ($count/$max_tries)" + return 0 + fi + echo "Card $card found, but control '$control' not ready yet ($count/$max_tries)" + else + echo "Card $card not ready yet ($count/$max_tries)" fi - # Check if PipeWire is running - if pw-cli info 0 >/dev/null 2>&1; then - echo "✅ PipeWire is running (checked $COUNT/$MAX_TRIES)" - return 0 - fi - - echo "⏳ PipeWire not running yet ($COUNT/$MAX_TRIES), retrying in $SLEEP_SEC s..." - sleep $SLEEP_SEC + sleep "$sleep_sec" done - echo "❌ PipeWire did not start after $MAX_TRIES seconds" - return 2 + echo "Card $card with control '$control' did not become ready" + return 1 +} + +set_control_if_exists() { + local card="$1" + local control="$2" + local value="$3" + + if amixer -c "$card" scontrols | grep -Fq "'$control'"; then + echo "Setting $control on $card to $value" + amixer -c "$card" set "$control" "$value" + return 0 + fi + + echo "Control '$control' not found on $card, skipping" + return 0 } -# Run pipewire check -check_pipewire - -# Sleep 2 seconds to give the audio service some time to be fully loaded -sleep 2 - -if amixer -c seeed2micvoicec info >/dev/null 2>&1; then - echo "seeed2micvoicec found" - amixer -c seeed2micvoicec set Headphone 100% - amixer -c seeed2micvoicec set Speaker 100% - amixer set Master 100% -elif amixer -c Lite info >/dev/null 2>&1; then - echo "Lite found" - amixer -c Lite set Headphone 100% - amixer -c Lite set Speaker 100% - amixer set Master 100% +if wait_for_card_and_control seeed2micvoicec Headphone; then + CARD="seeed2micvoicec" + echo "seeed2micvoicec found" +elif wait_for_card_and_control Lite Headphone; then + CARD="Lite" + echo "Lite found" else - exit 1 + echo "No supported sound card became ready" + exit 1 fi +set_control_if_exists "$CARD" Headphone 100% +set_control_if_exists "$CARD" Speaker 100% +set_control_if_exists "$CARD" Master 100% +set_control_if_exists "$CARD" PCM 100% + +# Set pipewire sink to 100% +wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0 + +# Alsa save alsactl store diff --git a/02-stage-audiodriver-other/01-set-audio-volume/files/configure_audio.sh b/02-stage-audiodriver-other/01-set-audio-volume/files/configure_audio.sh index 871dbdf..9c49b4b 100644 --- a/02-stage-audiodriver-other/01-set-audio-volume/files/configure_audio.sh +++ b/02-stage-audiodriver-other/01-set-audio-volume/files/configure_audio.sh @@ -1,51 +1,66 @@ #!/bin/bash +set -u -check_pipewire() { - local MAX_TRIES=30 - local SLEEP_SEC=1 - local COUNT=0 +wait_for_card_and_control() { + local card="$1" + local control="$2" + local max_tries=30 + local sleep_sec=1 + local count=0 - while [ $COUNT -lt $MAX_TRIES ]; do - COUNT=$((COUNT + 1)) + while [ "$count" -lt "$max_tries" ]; do + count=$((count + 1)) - # Check if XDG_RUNTIME_DIR is set - if [ -z "$XDG_RUNTIME_DIR" ]; then - echo "❌ XDG_RUNTIME_DIR is not set" - return 1 + if amixer -c "$card" info >/dev/null 2>&1; then + if amixer -c "$card" scontrols | grep -Fq "'$control'"; then + echo "Card $card with control '$control' is ready ($count/$max_tries)" + return 0 + fi + echo "Card $card found, but control '$control' not ready yet ($count/$max_tries)" + else + echo "Card $card not ready yet ($count/$max_tries)" fi - # Check if PipeWire is running - if pw-cli info 0 >/dev/null 2>&1; then - echo "✅ PipeWire is running (checked $COUNT/$MAX_TRIES)" - return 0 - fi - - echo "⏳ PipeWire not running yet ($COUNT/$MAX_TRIES), retrying in $SLEEP_SEC s..." - sleep $SLEEP_SEC + sleep "$sleep_sec" done - echo "❌ PipeWire did not start after $MAX_TRIES seconds" - return 2 + echo "Card $card with control '$control' did not become ready" + return 1 +} + +set_control_if_exists() { + local card="$1" + local control="$2" + local value="$3" + + if amixer -c "$card" scontrols | grep -Fq "'$control'"; then + echo "Setting $control on $card to $value" + amixer -c "$card" set "$control" "$value" + return 0 + fi + + echo "Control '$control' not found on $card, skipping" + return 0 } -# Run pipewire check -check_pipewire - -# Sleep 2 seconds to give the audio service some time to be fully loaded -sleep 2 - -if amixer -c seeed2micvoicec info >/dev/null 2>&1; then - echo "seeed2micvoicec found" - amixer -c seeed2micvoicec set Headphone 100% - amixer -c seeed2micvoicec set Speaker 100% - amixer set Master 100% -elif amixer -c Lite info >/dev/null 2>&1; then - echo "Lite found" - amixer -c Lite set Headphone 100% - amixer -c Lite set Speaker 100% - amixer set Master 100% +if wait_for_card_and_control seeed2micvoicec Headphone; then + CARD="seeed2micvoicec" + echo "seeed2micvoicec found" +elif wait_for_card_and_control Lite Headphone; then + CARD="Lite" + echo "Lite found" else - exit 1 + echo "No supported sound card became ready" + exit 1 fi +set_control_if_exists "$CARD" Headphone 100% +set_control_if_exists "$CARD" Speaker 100% +set_control_if_exists "$CARD" Master 100% +set_control_if_exists "$CARD" PCM 100% + +# Set pipewire sink to 100% +wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0 + +# Alsa save alsactl store diff --git a/02-stage-audiodriver-respeaker_lite/02-set-audio-volume/files/configure_audio.sh b/02-stage-audiodriver-respeaker_lite/02-set-audio-volume/files/configure_audio.sh index 871dbdf..9c49b4b 100644 --- a/02-stage-audiodriver-respeaker_lite/02-set-audio-volume/files/configure_audio.sh +++ b/02-stage-audiodriver-respeaker_lite/02-set-audio-volume/files/configure_audio.sh @@ -1,51 +1,66 @@ #!/bin/bash +set -u -check_pipewire() { - local MAX_TRIES=30 - local SLEEP_SEC=1 - local COUNT=0 +wait_for_card_and_control() { + local card="$1" + local control="$2" + local max_tries=30 + local sleep_sec=1 + local count=0 - while [ $COUNT -lt $MAX_TRIES ]; do - COUNT=$((COUNT + 1)) + while [ "$count" -lt "$max_tries" ]; do + count=$((count + 1)) - # Check if XDG_RUNTIME_DIR is set - if [ -z "$XDG_RUNTIME_DIR" ]; then - echo "❌ XDG_RUNTIME_DIR is not set" - return 1 + if amixer -c "$card" info >/dev/null 2>&1; then + if amixer -c "$card" scontrols | grep -Fq "'$control'"; then + echo "Card $card with control '$control' is ready ($count/$max_tries)" + return 0 + fi + echo "Card $card found, but control '$control' not ready yet ($count/$max_tries)" + else + echo "Card $card not ready yet ($count/$max_tries)" fi - # Check if PipeWire is running - if pw-cli info 0 >/dev/null 2>&1; then - echo "✅ PipeWire is running (checked $COUNT/$MAX_TRIES)" - return 0 - fi - - echo "⏳ PipeWire not running yet ($COUNT/$MAX_TRIES), retrying in $SLEEP_SEC s..." - sleep $SLEEP_SEC + sleep "$sleep_sec" done - echo "❌ PipeWire did not start after $MAX_TRIES seconds" - return 2 + echo "Card $card with control '$control' did not become ready" + return 1 +} + +set_control_if_exists() { + local card="$1" + local control="$2" + local value="$3" + + if amixer -c "$card" scontrols | grep -Fq "'$control'"; then + echo "Setting $control on $card to $value" + amixer -c "$card" set "$control" "$value" + return 0 + fi + + echo "Control '$control' not found on $card, skipping" + return 0 } -# Run pipewire check -check_pipewire - -# Sleep 2 seconds to give the audio service some time to be fully loaded -sleep 2 - -if amixer -c seeed2micvoicec info >/dev/null 2>&1; then - echo "seeed2micvoicec found" - amixer -c seeed2micvoicec set Headphone 100% - amixer -c seeed2micvoicec set Speaker 100% - amixer set Master 100% -elif amixer -c Lite info >/dev/null 2>&1; then - echo "Lite found" - amixer -c Lite set Headphone 100% - amixer -c Lite set Speaker 100% - amixer set Master 100% +if wait_for_card_and_control seeed2micvoicec Headphone; then + CARD="seeed2micvoicec" + echo "seeed2micvoicec found" +elif wait_for_card_and_control Lite Headphone; then + CARD="Lite" + echo "Lite found" else - exit 1 + echo "No supported sound card became ready" + exit 1 fi +set_control_if_exists "$CARD" Headphone 100% +set_control_if_exists "$CARD" Speaker 100% +set_control_if_exists "$CARD" Master 100% +set_control_if_exists "$CARD" PCM 100% + +# Set pipewire sink to 100% +wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0 + +# Alsa save alsactl store From 3c552d6a996f623a87c6f05ea0de81898cfc7529 Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Sat, 18 Apr 2026 04:32:14 +0200 Subject: [PATCH 2/2] fix(audio): remove duplicate install and add wireplumber configs Remove duplicated pipewire config installation line. Add installation of default volume and disabled ACP profile wireplumber configuration files for proper audio setup. --- 01-stage-picompose/03-install-pipewire-audio/02-run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/01-stage-picompose/03-install-pipewire-audio/02-run.sh b/01-stage-picompose/03-install-pipewire-audio/02-run.sh index a4e4b3d..0bf63ae 100755 --- a/01-stage-picompose/03-install-pipewire-audio/02-run.sh +++ b/01-stage-picompose/03-install-pipewire-audio/02-run.sh @@ -7,7 +7,8 @@ mkdir -p "${ROOTFS_DIR}/etc/wireplumber/wireplumber.conf.d" # Copy configs install -v -m 644 files/linux-voice-assistant.conf "${ROOTFS_DIR}/etc/pipewire.conf.d/linux-voice-assistant.conf" -install -v -m 644 files/linux-voice-assistant.conf "${ROOTFS_DIR}/etc/pipewire.conf.d/linux-voice-assistant.conf" +install -v -m 644 files/50-volume.conf "${ROOTFS_DIR}/etc/wireplumber/wireplumber.conf.d/50-volume.conf" +install -v -m 644 files/51-disable-acp.conf "${ROOTFS_DIR}/etc/wireplumber/wireplumber.conf.d/51-disable-acp.conf" on_chroot << EOF # Activate PipeWire-ALSA Bridge