Skip to content

Commit

Permalink
refactored disable onboard audio.
Browse files Browse the repository at this point in the history
only execute if flag is true. inlined function
  • Loading branch information
AlvinSchiller committed Nov 20, 2023
1 parent 2a0d42a commit 1ed72d5
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions installation/routines/set_raspi_config.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
#!/usr/bin/env bash

_get_onboard_audio() {
if grep -q -E "^dtparam=([^,]*,)*audio=(on|true|yes|1).*" ${RPI_BOOT_CONFIG_FILE}
then
echo 1
else
echo 0
fi
}

_run_set_raspi_config() {
# Source: https://raspberrypi.stackexchange.com/a/66939

Expand All @@ -25,16 +16,15 @@ _run_set_raspi_config() {
sudo iwconfig wlan0 power off

# On-board audio
if [[ $(_get_onboard_audio) -eq 1 ]]; then
DISABLE_ONBOARD_AUDIO=${DISABLE_ONBOARD_AUDIO:-false}
if [[ $DISABLE_ONBOARD_AUDIO = true ]]; then
echo " Disable on-chip BCM audio"
if [ "$DISABLE_ONBOARD_AUDIO" == true ]; then
echo " Disable on-chip BCM audio"
if grep -q -E "^dtparam=([^,]*,)*audio=(on|true|yes|1).*" "${RPI_BOOT_CONFIG_FILE}" ; then
echo " Backup ${RPI_BOOT_CONFIG_FILE} --> ${DISABLE_ONBOARD_AUDIO_BACKUP}"
sudo cp "${RPI_BOOT_CONFIG_FILE}" "${DISABLE_ONBOARD_AUDIO_BACKUP}"
sudo sed -i "s/^\(dtparam=\([^,]*,\)*\)audio=\(on\|true\|yes\|1\)\(.*\)/\1audio=off\4/g" "${RPI_BOOT_CONFIG_FILE}"
else
echo " On board audio seems to be off already. Not touching ${RPI_BOOT_CONFIG_FILE}"
fi
else
echo " On board audio seems to be off already. Not touching ${RPI_BOOT_CONFIG_FILE}"
fi
}

Expand Down

0 comments on commit 1ed72d5

Please sign in to comment.