2022-02-06 11:29:12 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius)
|
|
|
|
|
|
|
|
. /etc/profile
|
|
|
|
|
2022-10-21 21:23:25 +00:00
|
|
|
AUDIO_DEVICE="$(aplay -L | awk 'BEGIN{ FS=":"} /[a-z]:/ {print $1; exit}')"
|
|
|
|
if [[ "${AUDIO_DEVICE}" =~ hdmi ]]
|
|
|
|
then
|
|
|
|
cat <<EOF >/storage/.config/asound.conf
|
|
|
|
pcm.!default {
|
|
|
|
type plug
|
|
|
|
slave {
|
|
|
|
pcm "hdmi:0,0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctl.!default {
|
|
|
|
type hw
|
|
|
|
card 0
|
|
|
|
}
|
|
|
|
EOF
|
2022-10-21 23:59:00 +00:00
|
|
|
else
|
2022-02-06 11:29:12 +00:00
|
|
|
cp /usr/config/asound.conf /storage/.config
|
|
|
|
|
2022-10-21 23:59:00 +00:00
|
|
|
if [ ! -e "/storage/.config/asound.state" ] && [ -e /usr/config/asound.state ]
|
|
|
|
then
|
|
|
|
cp /usr/config/asound.state /storage/.config
|
|
|
|
fi
|
2022-05-27 22:33:28 +00:00
|
|
|
|
2022-10-21 23:59:00 +00:00
|
|
|
# Set the mixer in ES
|
|
|
|
sed -i 's#<string name="AudioDevice" value="'.*'" />#<string name="AudioDevice" value="'${DEVICE_AUDIO_MIXER}'" />#' /storage/.emulationstation/es_settings.cfg
|
2022-02-11 12:03:07 +00:00
|
|
|
|
2022-10-21 23:59:00 +00:00
|
|
|
# Initialize sound using the state if available.
|
|
|
|
if [ -e "/storage/.config/asound.state" ]
|
|
|
|
then
|
|
|
|
alsactl restore -f /storage/.config/asound.state
|
|
|
|
fi
|
2022-05-27 22:33:28 +00:00
|
|
|
fi
|
|
|
|
|
2022-02-06 11:29:12 +00:00
|
|
|
VOL=$(get_setting "audio.volume" 2>/dev/null)
|
2022-09-22 23:50:28 +00:00
|
|
|
amixer -M set "${DEVICE_AUDIO_MIXER}" ${VOL}%
|