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-23 11:19:33 +00:00
|
|
|
### Temporary device quirk for VCS
|
|
|
|
if [ -e "/usr/sbin/dmidecode" ] && \
|
|
|
|
[ ! -e "/storage/.config/modprobe.d/alsa-base.conf" ]
|
|
|
|
then
|
|
|
|
THIS_DEVICE="$(/usr/sbin/dmidecode -s system-product-name)"
|
|
|
|
if [[ "${THIS_DEVICE}" =~ ^VCS ]]
|
|
|
|
then
|
2022-10-23 14:37:21 +00:00
|
|
|
if [ ! -d "/storage/.config/modprobe.d/" ]
|
|
|
|
then
|
|
|
|
mkdir -p /storage/.config/modprobe.d
|
|
|
|
fi
|
2022-10-23 11:19:33 +00:00
|
|
|
touch /storage/.config/modprobe.d/alsa-base.conf
|
2022-10-26 16:01:28 +00:00
|
|
|
set-audio "DEFAULT HDMI"
|
2022-10-23 14:36:45 +00:00
|
|
|
reboot
|
|
|
|
fi
|
2022-10-23 11:19:33 +00:00
|
|
|
fi
|
|
|
|
|
2022-10-22 15:11:33 +00:00
|
|
|
if [ ! -e "/storage/.config/asound.conf" ]
|
2022-10-21 21:23:25 +00:00
|
|
|
then
|
2022-10-26 16:01:28 +00:00
|
|
|
set-audio "DEFAULT (SYSTEM PROVIDED)"
|
2022-10-22 15:11:33 +00:00
|
|
|
fi
|
2022-10-22 13:45:45 +00:00
|
|
|
|
2022-10-22 15:11:33 +00:00
|
|
|
if [ ! -e "/storage/.config/asound.state" ] && [ -e /usr/config/asound.state ]
|
2022-10-22 13:45:45 +00:00
|
|
|
then
|
2022-10-22 15:11:33 +00:00
|
|
|
cp /usr/config/asound.state /storage/.config
|
2022-10-22 13:45:45 +00:00
|
|
|
fi
|
2022-02-06 11:29:12 +00:00
|
|
|
|
2022-11-09 12:28:56 +00:00
|
|
|
AUDIODEVICE=$(get_setting system.audiodevice)
|
|
|
|
AUDIOTEST=$(grep "${AUDIODEVICE}" /storage/.config/emulationstation/es_settings.cfg 2>/dev/null)
|
|
|
|
if [ ! "$?" = 0 ]
|
2022-11-06 23:19:44 +00:00
|
|
|
then
|
2022-11-09 12:28:56 +00:00
|
|
|
sed -i '/^.*AudioCard.*$/a \\t<string name="AudioDevice" value="${AUDIODEVICE}" \/>' /storage/.config/emulationstation/es_settings.cfg
|
|
|
|
else
|
|
|
|
if [ -z "${AUDIODEVICE}" ]
|
2022-11-06 23:19:44 +00:00
|
|
|
then
|
2022-11-09 12:28:56 +00:00
|
|
|
sed -i '/<string name="AudioDevice".*$/d' /storage/.emulationstation/es_settings.cfg
|
2022-11-06 23:19:44 +00:00
|
|
|
fi
|
|
|
|
fi
|
2022-05-27 22:33:28 +00:00
|
|
|
|
2022-10-22 15:11:33 +00:00
|
|
|
# Initialize sound using the state if available.
|
|
|
|
if [ -e "/storage/.config/asound.state" ]
|
|
|
|
then
|
|
|
|
alsactl restore -f /storage/.config/asound.state
|
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}%
|