#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius) . /etc/profile AUDIO_DEVICE="$(aplay -L | awk 'BEGIN{ FS=":"} /[a-z]:/ {print $1; exit}')" if [[ "${AUDIO_DEVICE}" =~ hdmi ]] then cat </storage/.config/asound.conf pcm.!default { type plug slave { pcm "hdmi:0,0" } } ctl.!default { type hw card 0 } EOF if [ -e "/storage/.config/modprobe.d/alsa-base.conf" ] then touch /storage/.config/modprobe.d/alsa-base.conf reboot fi else if [ -e "/storage/.config/modprobe.d/alsa-base.conf" ] then rm -f /storage/.config/modprobe.d/alsa-base.conf reboot fi cp /usr/config/asound.conf /storage/.config if [ ! -e "/storage/.config/asound.state" ] && [ -e /usr/config/asound.state ] then cp /usr/config/asound.state /storage/.config fi # Set the mixer in ES sed -i 's###' /storage/.emulationstation/es_settings.cfg # Initialize sound using the state if available. if [ -e "/storage/.config/asound.state" ] then alsactl restore -f /storage/.config/asound.state fi fi VOL=$(get_setting "audio.volume" 2>/dev/null) amixer -M set "${DEVICE_AUDIO_MIXER}" ${VOL}%