Gerador de ~/.asoundrc script

 #!/bin/bash

ls sound.pin &>/dev/null && echo It will not be generated because there is sound.pin && exit

# aplay -L
card_name="$(aplay -L | grep front | sed 's/\(front:\|CARD=\)//g' | cut -d, -f1)"
number_device="$(aplay -L | grep front | cut -d, -f2 | tr -d DEV=)"


echo defaults.pcm.!card $card_name >>sound.pin
echo defaults.pcm.!device $number_device >>sound.pin
echo defaults.pcm.!ctl $card_name >>sound.pin


# aplay --list-devices
# Verificar linguagem
lig_comm="$(aplay --list-devices | sed -n "2p" | cut -d: -f1 | tr -d "[0-9]")"
#  Número da placa
number_card="$(aplay --list-devices | sed -n "2p" | cut -d: -f1 | tr -d "($lig_comm| )")"
# Verificar linguagem
lig_disp="$(aplay --list-devices | sed -n "2p" | cut -d, -f2 | cut -d: -f1 | tr -d "[0-9] ")"
#  Número do dispositivo  
number_disp="$(aplay --list-devices | sed -n "2p" | cut -d, -f2 | cut -d: -f1 | tr -d "($lig_disp| )")"

echo pcm.!spdif { >>sound.pin
echo type hw       >>sound.pin
echo card $number_card >>sound.pin
echo device $number_disp >>sound.pin
echo } >>sound.pin
echo >>sound.pin
echo pcm.!default { >>sound.pin
echo type plug >>sound.pin
echo slave { >>sound.pin
echo pcm \"spdif\" >>sound.pin
echo   } >>sound.pin
echo } >>sound.pin

Comentários

Postagens mais visitadas deste blog

Script precisa do sudo para dar a permissão ao um comando fazer algo ....

Variável de { . Variável de matriz

Filtragem de strings no terminal