From 87b27fbc779ca2069d3a4ef6118570c9dec48073 Mon Sep 17 00:00:00 2001 From: Pecusx Date: Thu, 17 Nov 2016 17:52:57 +0100 Subject: [PATCH] Scripts are needed to change audio configuration. --- html/scripts/get_audio_info.sh | 5 +++++ html/scripts/set_audio.sh | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 html/scripts/get_audio_info.sh create mode 100644 html/scripts/set_audio.sh diff --git a/html/scripts/get_audio_info.sh b/html/scripts/get_audio_info.sh new file mode 100644 index 0000000..a1e3b44 --- /dev/null +++ b/html/scripts/get_audio_info.sh @@ -0,0 +1,5 @@ +aplay -l | grep "card 0" -m 1 +amixer -c0 scontrols | grep "Simple" -m 1 +aplay -l | grep "card 1" -m 1 +amixer -c1 scontrols | grep "Simple" -m 1 + diff --git a/html/scripts/set_audio.sh b/html/scripts/set_audio.sh new file mode 100644 index 0000000..ba42318 --- /dev/null +++ b/html/scripts/set_audio.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Files to modify + +BOOTCONFIG=/boot/config.txt +MPDCONFIG=/etc/mpd.conf +CARDPRIORYTY=/lib/modprobe.d/aliases.conf + +INTERNALFIRST=/usr/share/radio/hardware/audio/internal.conf +USBFIRST=/usr/share/radio/hardware/audio/usb.conf + +# Only if 3 params +if [ $# = 3 ]; then + # Get parameters from commandline + + # "internal or "usb" + CARD=$1 + # Mixer name for volume control + MIXER=$2 + # PWM mode 1 - standard , 2 - high quality + PWM=$3 + + # Set prioryty of audio device + if [ ${CARD} = "internal" ]; then + cp ${INTERNALFIRST} ${CARDPRIORYTY} + elif [ ${CARD} = "usb" ]; then + cp ${USBFIRST} ${CARDPRIORYTY} + fi + + # Set PWM mode + sed -i "s/audio_pwm_mode.*/audio_pwm_mode=${PWM}/" ${BOOTCONFIG} + + # Set mixer name + sed -i "s/^[ \t]*mixer_control.*/\tmixer_control\t\"${MIXER}\"/" ${MPDCONFIG} + + reboot +fi