Make alsa audio sink and source permanent / automation on connect

  • I have LibreELEC (official) Version: 8.0.2 installed and managed to stream audio via Bluetooth. The raspi is configured to route Audio from Kodi to the HDMI out, Bluetooth audio to a second analogue port.

    I have available: alsa_output.platform-soc_sound.analog-stereo module-alsa-card.c s16le 2ch 44100Hz

    To activate audio I connected the Bluetooth device to Kodi and did:

    Code
    # systemctl stop kodi
    # pactl load-module module-udev-d
    # pactl set-default-sink alsa_output.platform-soc_sound.analog-stereo
    # pactl set-default-source bluez_source.B4_9D_0B_95_D0_BE
    # systemctl start kodi

    This works fine, but when I reboot the configuration has been lost. Is there a way to make this permanent or start s script as soon a bluetooth connection is established.

    Thank you for your hints!

    Bret

  • You can create a systemd .service in /storage/.config/system.d/ to run the commands. This approach will allow you to control when the commands are run in the boot sequence, e.g. before Kodi starts.