From 77305ed3b9f5e19bf2c85bd02bf8842041fc727d Mon Sep 17 00:00:00 2001 From: Spencer Bull Date: Tue, 25 Aug 2026 15:29:27 -0500 Subject: [PATCH] Enable Dell XPS 13 sidecar speaker amplifiers (#7032) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Dell XPS 13 DX13260 drives its two CS35L56 sidecar speaker amplifiers through a quirk that Linux only gains in 7.2, so until Arch ships that kernel the machine plays through one amplifier with no bass. The dell-xps13-sidecar-amps package selects the same driver path with a module override; this installs it on that exact machine and nowhere else. The detector requires both the DX13260 product name and SKU 0E53, because the override forces a quirk value rather than merging into one, and a machine that gets it wrong loses whatever quirk the kernel would have chosen for itself. Pacman registers a package even when its post_install scriptlet fails, so the leaf calls dell-xps13-sidecar-amps-apply itself instead of trusting the install to have applied: a failed cleanup or boot-image rebuild has to reach the caller rather than hide behind a package pacman considers installed. That is also why the migration marks reboot-required only after the apply succeeds — a migration that exits non-zero keeps no completion marker and retries the apply on the next run, even though pacman already has the package. The leaf runs after intel/ptl-kernel.sh rather than beside the other Dell leaf at the top of install/hardware/all.sh, so its boot-image rebuild sees the Panther Lake kernel that step swaps in rather than the stock one it removes. Co-authored-by: Codex XHigh --- bin/omarchy-hw-dell-xps13-sidecar-amps | 8 ++ install/hardware/all.sh | 4 + install/hardware/dell-xps13-sidecar-amps.sh | 10 ++ install/omarchy-other.packages | 1 + migrations/1787666837.sh | 6 + test/shell.d/xps13-sidecar-amps-test.sh | 147 ++++++++++++++++++++ 6 files changed, 176 insertions(+) create mode 100755 bin/omarchy-hw-dell-xps13-sidecar-amps create mode 100644 install/hardware/dell-xps13-sidecar-amps.sh create mode 100644 migrations/1787666837.sh create mode 100755 test/shell.d/xps13-sidecar-amps-test.sh diff --git a/bin/omarchy-hw-dell-xps13-sidecar-amps b/bin/omarchy-hw-dell-xps13-sidecar-amps new file mode 100755 index 00000000..ecc206fa --- /dev/null +++ b/bin/omarchy-hw-dell-xps13-sidecar-amps @@ -0,0 +1,8 @@ +#!/bin/bash + +# omarchy:summary=Match the Dell XPS 13 DX13260 that requires the sidecar amplifier workaround. + +product_sku="${OMARCHY_DMI_PRODUCT_SKU:-/sys/class/dmi/id/product_sku}" + +omarchy-hw-match "DX13260" && + grep -qix "0E53" "$product_sku" 2>/dev/null diff --git a/install/hardware/all.sh b/install/hardware/all.sh index 6adcff9c..9b54d1c0 100644 --- a/install/hardware/all.sh +++ b/install/hardware/all.sh @@ -25,6 +25,10 @@ run_logged "$OMARCHY_INSTALL/hardware/intel/fred.sh" run_logged "$OMARCHY_INSTALL/hardware/intel/fix-wifi7-eht.sh" run_logged "$OMARCHY_INSTALL/hardware/intel/sof-firmware.sh" +# Rebuilds the boot image, so it has to follow the Panther Lake kernel swap +# above rather than sit with the other Dell leaf at the top of this file. +run_logged "$OMARCHY_INSTALL/hardware/dell-xps13-sidecar-amps.sh" + run_logged "$OMARCHY_INSTALL/hardware/asus/fix-asus-ptl-display-backlight.sh" run_logged "$OMARCHY_INSTALL/hardware/asus/fix-asus-ptl-b9406-display.sh" run_logged "$OMARCHY_INSTALL/hardware/asus/fix-asus-ptl-b9406-touchpad.sh" diff --git a/install/hardware/dell-xps13-sidecar-amps.sh b/install/hardware/dell-xps13-sidecar-amps.sh new file mode 100644 index 00000000..5682b595 --- /dev/null +++ b/install/hardware/dell-xps13-sidecar-amps.sh @@ -0,0 +1,10 @@ +# Enable the temporary sidecar amplifier workaround on the exact Dell XPS 13 model that needs it. +# +# Pacman registers a package even when its post_install scriptlet fails, so the +# apply command runs explicitly here: a failed cleanup or boot-image rebuild has +# to reach the caller rather than hide behind a successfully registered package. + +if omarchy-hw-dell-xps13-sidecar-amps; then + omarchy-pkg-add dell-xps13-sidecar-amps && + sudo dell-xps13-sidecar-amps-apply +fi diff --git a/install/omarchy-other.packages b/install/omarchy-other.packages index 02ac645e..e5d56d56 100644 --- a/install/omarchy-other.packages +++ b/install/omarchy-other.packages @@ -61,6 +61,7 @@ linux-firmware-marvell # Dell laptop support packages dell-xps-touchpad-haptics +dell-xps13-sidecar-amps # Speaker tunings (LV2 limiter every tuning ends in) lsp-plugins-lv2 diff --git a/migrations/1787666837.sh b/migrations/1787666837.sh new file mode 100644 index 00000000..33c5d9dc --- /dev/null +++ b/migrations/1787666837.sh @@ -0,0 +1,6 @@ +echo "Enable Dell XPS 13 sidecar speaker amplifiers" + +if omarchy-hw-dell-xps13-sidecar-amps; then + source "$OMARCHY_PATH/install/hardware/dell-xps13-sidecar-amps.sh" + omarchy-state set reboot-required +fi diff --git a/test/shell.d/xps13-sidecar-amps-test.sh b/test/shell.d/xps13-sidecar-amps-test.sh new file mode 100755 index 00000000..d82498f9 --- /dev/null +++ b/test/shell.d/xps13-sidecar-amps-test.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +detector="$ROOT/bin/omarchy-hw-dell-xps13-sidecar-amps" +leaf="$ROOT/install/hardware/dell-xps13-sidecar-amps.sh" +all="$ROOT/install/hardware/all.sh" +migration=$(grep -l "dell-xps13-sidecar-amps" "$ROOT"/migrations/*.sh | head -1) + +grep -q 'run_logged .*hardware/dell-xps13-sidecar-amps.sh' "$all" || + fail "the sidecar amplifier workaround runs during hardware setup" +pass "the sidecar amplifier workaround runs during hardware setup" + +# The apply step rebuilds the boot image, so it has to see the Panther Lake +# kernel that ptl-kernel.sh swaps in rather than the stock one it replaces. +ptl_line=$(grep -n 'hardware/intel/ptl-kernel.sh' "$all" | cut -d: -f1) +amps_line=$(grep -n 'hardware/dell-xps13-sidecar-amps.sh' "$all" | cut -d: -f1) +((ptl_line < amps_line)) || + fail "the sidecar amplifier workaround runs after the Panther Lake kernel swap" +pass "the sidecar amplifier workaround runs after the Panther Lake kernel swap" + +[[ -n $migration ]] || fail "a migration enables the workaround on existing installs" +pass "a migration enables the workaround on existing installs" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT +mkdir -p "$test_tmp/bin" + +cat >"$test_tmp/bin/omarchy-hw-match" <<'SH' +#!/bin/bash +[[ ${TEST_PRODUCT_NAME:-} == *"$1"* ]] +SH + +cat >"$test_tmp/bin/omarchy-pkg-add" <<'SH' +#!/bin/bash +printf 'pkg-add %s\n' "$*" >>"$CALL_LOG" +exit "${TEST_PKG_ADD_STATUS:-0}" +SH + +cat >"$test_tmp/bin/sudo" <<'SH' +#!/bin/bash +exec "$@" +SH + +cat >"$test_tmp/bin/dell-xps13-sidecar-amps-apply" <<'SH' +#!/bin/bash +printf 'apply\n' >>"$CALL_LOG" +exit "${TEST_APPLY_STATUS:-0}" +SH + +cat >"$test_tmp/bin/omarchy-state" <<'SH' +#!/bin/bash +printf 'state %s\n' "$*" >>"$CALL_LOG" +SH + +chmod +x "$test_tmp/bin"/* + +sku_file="$test_tmp/product_sku" +call_log="$test_tmp/calls.log" + +run_detector() { + printf '%s\n' "${2-0E53}" >"$sku_file" + PATH="$test_tmp/bin:$PATH" \ + TEST_PRODUCT_NAME="${1-XPS 13 DX13260}" \ + OMARCHY_DMI_PRODUCT_SKU="${3-$sku_file}" \ + bash "$detector" +} + +run_detector || fail "the detector matches the DX13260 with SKU 0E53" +pass "the detector matches the DX13260 with SKU 0E53" + +run_detector "XPS 13 DX13261" && fail "the detector rejects another model" +pass "the detector rejects another model" + +run_detector "XPS 13 DX13260" "0E54" && fail "the detector rejects another SKU" +pass "the detector rejects another SKU" + +# An exact match must not be satisfied by a SKU that merely contains it. +run_detector "XPS 13 DX13260" "0E530" && fail "the detector rejects a longer SKU" +pass "the detector rejects a longer SKU" + +run_detector "XPS 13 DX13260" "0E53" "$test_tmp/absent" && + fail "the detector fails closed when the SKU attribute is missing" +pass "the detector fails closed when the SKU attribute is missing" + +# Sourced the way run_logged runs it. +run_leaf() { + : >"$call_log" + printf '0E53\n' >"$sku_file" + PATH="$test_tmp/bin:$ROOT/bin:$PATH" \ + CALL_LOG="$call_log" \ + TEST_PRODUCT_NAME="${1-XPS 13 DX13260}" \ + TEST_PKG_ADD_STATUS="${2:-0}" \ + TEST_APPLY_STATUS="${3:-0}" \ + OMARCHY_DMI_PRODUCT_SKU="$sku_file" \ + bash -c 'source "$1"' bash "$leaf" +} + +run_leaf || fail "the leaf installs and applies on the target machine" +grep -q 'pkg-add dell-xps13-sidecar-amps' "$call_log" || + fail "the leaf installs the package on the target machine" +grep -q '^apply$' "$call_log" || + fail "the leaf applies the workaround on the target machine" +pass "the leaf installs and applies on the target machine" + +run_leaf "ThinkPad X1" || fail "the leaf no-ops on other hardware" +[[ -s $call_log ]] && fail "the leaf no-ops on other hardware" +pass "the leaf no-ops on other hardware" + +# Pacman registers a package even when its scriptlet fails, so a failing apply +# has to surface rather than be swallowed by a successful install. +run_leaf "XPS 13 DX13260" 0 1 && fail "a failing apply fails the leaf" +pass "a failing apply fails the leaf" + +run_leaf "XPS 13 DX13260" 1 && fail "a failing package install fails the leaf" +grep -q '^apply$' "$call_log" && fail "a failing package install skips the apply" +pass "a failing package install fails the leaf without applying" + +# The migration runner uses bash -euo pipefail and only records the migration +# when it exits clean, so a failed apply has to leave reboot-required unset. +run_migration() { + : >"$call_log" + printf '0E53\n' >"$sku_file" + PATH="$test_tmp/bin:$ROOT/bin:$PATH" \ + CALL_LOG="$call_log" \ + OMARCHY_PATH="$ROOT" \ + TEST_PRODUCT_NAME="${1-XPS 13 DX13260}" \ + TEST_APPLY_STATUS="${2:-0}" \ + OMARCHY_DMI_PRODUCT_SKU="$sku_file" \ + bash -euo pipefail "$migration" >/dev/null +} + +run_migration || fail "the migration applies the workaround and asks for a reboot" +grep -q 'state set reboot-required' "$call_log" || + fail "the migration applies the workaround and asks for a reboot" +pass "the migration applies the workaround and asks for a reboot" + +run_migration "XPS 13 DX13260" 1 && fail "a failing apply leaves the migration pending" +grep -q 'state set reboot-required' "$call_log" && + fail "a failing apply does not mark reboot-required" +pass "a failing apply leaves the migration pending without marking reboot-required" + +run_migration "ThinkPad X1" || fail "the migration no-ops on other hardware" +[[ -s $call_log ]] && fail "the migration no-ops on other hardware" +pass "the migration no-ops on other hardware"