Artix Linux Forum

Artix Linux => System => Topic started by: jrballesteros05 on 13 August 2020, 17:04:14

Title: Set Bluealsa default when Headset is connected and Hwcard when it's disconnected
Post by: jrballesteros05 on 13 August 2020, 17:04:14
Hello everybody.

I am tryng to get rid of pulseaudio, I wrote kind of script for s6 to start bluealsa and I follow the steps from official page (https://github.com/Arkq/bluez-alsa).

Everything is working fine. Except for one thing that I don't how to fancy it.

I created a .asoundrc file with this:

Code: [Select]
defaults.bluealsa.service "org.bluealsa"
defaults.bluealsa.device  <MydeviceID>
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000

Then if I want my sound through my headset I should execute this:

Code: [Select]
aplay -D bluealsa 

If I change the .asoundrc file to this:


Code: [Select]
defaults.bluealsa.service "org.bluealsa"
defaults.bluealsa.device <MydeviceID>
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000
pcm.!default bluealsa
ctl.!default bluealsa

I don't have to specify "-D bluealsa" but when I disconnect my headset then I get the error.

Code: [Select]
ALSA lib bluealsa-pcm.c:892:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA PCM: PCM not found
aplay: main:830: audio open error: No such device

I know that behaviour is expected but I don't how to route audio to Headset when is connected and route to card when it's disconnected.  I've been reading about asoundrc but It's quite confusing for me.

I also read this (https://github.com/Arkq/bluez-alsa/issues/251)  and this (https://github.com/MichaIng/DietPi/issues/3456).

Did anyone have the same situation than I? I would appreciate any help.

Best regards.