Preparing for sound device control in ES.

This commit is contained in:
fewtarius 2022-11-09 07:25:04 -05:00
parent 38bc64dd19
commit a2be76d26d
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
2 changed files with 45 additions and 16 deletions

View file

@ -0,0 +1,45 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2020 Fewtarius (https://github.com/fewtarius)
. /etc/profile
ES_SETTINGS="/storage/.config/emulationstation/es_settings.cfg"
get_controls() {
IFS=""
CONTROLS=$(amixer controls | sed -e 's#^.*name=##g' -e "s#'##g")
for CONTROL in "${CONTROLS[@]}"
do
echo ${CONTROL} | awk '{print $1}' | grep -v -E 'Mic|Extension|Capture|Differential|Left|Right' | uniq
done
echo "--------"
for CONTROL in "${CONTROLS[@]}"
do
echo ${CONTROL}
done
}
set_es() {
AUDIODEVICE=${1}
systemctl stop ${UI_SERVICE}
AUDIOTEST=$(grep "AudioDevice" ${ES_SETTINGS} 2>/dev/null)
if [ ! "$?" = 0 ]
then
sed -i '/^.*AudioCard.*$/a \\t<string name="AudioDevice" value="${AUDIODEVICE}" \/>' ${ES_SETTINGS}
else
sed -i '/<string name="AudioDevice".*$/d'
sed -i '/^.*AudioCard.*$/a \\t<string name="AudioDevice" value="${AUDIODEVICE}" \/>' ${ES_SETTINGS}
fi
set_setting system.audiodevice "${AUDIODEVICE}"
systemctl start ${UI_SERVICE}
}
case ${1} in
controls)
get_controls 2>/dev/null
;;
set_es)
set_es $2
;;
esac

View file

@ -1,16 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2020 Fewtarius (https://github.com/fewtarius)
IFS=""
CONTROLS=$(amixer controls | sed -e 's#^.*name=##g' -e "s#'##g")
for CONTROL in "${CONTROLS[@]}"
do
echo ${CONTROL} | awk '{print $1}' | grep -v -E 'Mic|Extension|Capture|Differential|Left|Right' | uniq
done
echo "--------"
for CONTROL in "${CONTROLS[@]}"
do
echo ${CONTROL}
done