Skip to content

Instantly share code, notes, and snippets.

@ItsWendell
Created May 23, 2025 10:41
Show Gist options
  • Save ItsWendell/c9ea241f9644fb180fcde4d11ac688db to your computer and use it in GitHub Desktop.
Save ItsWendell/c9ea241f9644fb180fcde4d11ac688db to your computer and use it in GitHub Desktop.
ASUS Zenbook UX5406SA (Lunar Lake) audio fix
#!/bin/bash
# === WARNING: This script is AI generated and might not always work as expected ===
# ==============================================================================
# Script to fix audio on ASUS Zenbook UX5406SA (and similar models)
# with Lunar Lake CPUs on Fedora and other modern Linux distributions.
#
# This script automates the steps discussed, which involve:
# 1. Installing specific SOF (Sound Open Firmware) topology files.
# 2. Updating ALSA UCM (Use Case Manager) configuration files.
# 3. Forcing the snd-intel-dspcfg driver option.
# 4. Rebuilding the initramfs.
#
# Must be run with sudo or as root.
# ==============================================================================
# Exit immediately if a command exits with a non-zero status.
set -e
# --- Check for root privileges ---
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Please use 'sudo'."
exit 1
fi
echo "--- Starting Zenbook Audio Fix ---"
# --- Create a temporary directory for downloads ---
echo "[INFO] Creating a temporary directory for downloads..."
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
echo "[OK] Working in directory: $TEMP_DIR"
# --- 1. Install missing SOF firmware ---
echo ""
echo "--- Step 1: Downloading and installing SOF firmware ---"
FIRMWARE_URL="https://raw.githubusercontent.com/thesofproject/sof-bin/main/v2.12.x/sof-ipc4-tplg-v2.12.1/sof-lnl-cs42l43-l0-cs35l56-l23-2ch.tplg"
FIRMWARE_DEST_DIR="/lib/firmware/intel/sof-ipc4-tplg"
FIRMWARE_FILE="sof-lnl-cs42l43-l0-cs35l56-l23-2ch.tplg"
mkdir -p "$FIRMWARE_DEST_DIR"
echo "[INFO] Downloading firmware file..."
curl -L -O "$FIRMWARE_URL"
echo "[INFO] Installing firmware to $FIRMWARE_DEST_DIR"
mv "$FIRMWARE_FILE" "$FIRMWARE_DEST_DIR/"
echo "[OK] Firmware installed successfully."
# --- 2. Update ALSA UCM configuration files ---
echo ""
echo "--- Step 2: Downloading and updating ALSA UCM configuration ---"
UCM_REPO="https://github.com/alsa-project/alsa-ucm-conf.git"
UCM_DEST_DIR="/usr/share/alsa/ucm2/"
echo "[INFO] Cloning alsa-ucm-conf repository..."
git clone "$UCM_REPO"
echo "[INFO] Synchronizing sof-soundwire configuration..."
rsync -a --delete "alsa-ucm-conf/ucm2/sof-soundwire/" "${UCM_DEST_DIR}sof-soundwire/"
echo "[OK] ALSA UCM configuration updated."
# --- 3. Force SOF driver via modprobe ---
echo ""
echo "--- Step 3: Forcing SOF audio driver ---"
MODPROBE_CONF="/etc/modprobe.d/sof.conf"
echo "[INFO] Creating modprobe configuration file at $MODPROBE_CONF"
echo "options snd-intel-dspcfg dsp_driver=3" > "$MODPROBE_CONF"
echo "[OK] Modprobe configuration created."
# --- 4. Rebuild the initramfs ---
echo ""
echo "--- Step 4: Rebuilding initramfs with dracut ---"
echo "[INFO] This may take a few moments..."
dracut --force --regenerate-all
echo "[OK] Initramfs has been rebuilt."
# --- Cleanup and Final Instructions ---
echo ""
echo "--- Finalizing ---"
echo "[INFO] Removing temporary directory..."
rm -rf "$TEMP_DIR"
echo "[SUCCESS] Audio fix has been applied."
echo ""
echo "==================================================================="
echo "IMPORTANT: A reboot is required to apply all changes."
echo "Please save your work and reboot your system now."
echo "You can reboot by running: sudo reboot"
echo "==================================================================="
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment