Linux comes even with manned rockets nowadays which is fine because sound doesn’t work in space anyway. Sound configurations are an eternal curse in Linux setups, and it can be quite tricky to get different audio hosts to work simultaneously. As a Linux-musician I need to have my stuff quite well organized. I have both PulseAudio and JACK in use at the same time and there are luckily some pulseaudio jack sink packages for that. Still, I’ve had some issues when starting the JACK host with its custom commands or setting it as an application to run automatically after computer is booted. Apparently it takes a while after my computer recognizes my external audio interface. That’s why JACK refuses to start at first but then I can start it manually after the boot is fully complete.
For these reasons I decided to update my old bash script and run that automatically after the boot instead of qjackctl. This time it does not only wait for JACK to start before running the custom commands but it also waits at the beginning. That’s how my computer gets enough time for finding the interface, and everything starts automatically without the need to start any of these programs and commands manually. Whenever package updates or something else breaks the starting schedules, this script should compensate the faults, at least for me. And if my script also breaks, there’s probably simple solution: increase the sleep times.
So, here is the newly rebranded and updated script, “PASKA Audio Skripti Käynnistyksen Alkuun”, or freely translated as “DUMBASS Ultimate Meta-Boot Audio Setup Script” (formerly a.k.a “ASS Sound Script”):
#PASKA Audio Skripti Käynnistyksen Alkuun 0.5 (by Arello)
#Step 0: Search for misbehaving applications and kill them (irrelevant for the first boot-up)
if [ $(ps -auxc | grep jackdbus | wc -l ) = 1 ]; then
killall -KILL jackdbus
fi
if [ $(ps -auxc | grep qjackctl | wc -l ) = 1 ]; then
killall -KILL qjackctl
fi
#Step 1: Wait for boot to settle down
sleep 5
#Step 2: Then run JACK and waits for a moment before next commands, just in case
qjackctl -s & sleep 5
#Step 3: Sets jack sink as default and runs a2j MIDI bridge
pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source; pacmd set-default-sink jack_out && a2jmidid -e
Alternatively the last line could be “pactl set-default-sink jack_out && a2jmidid -e”, but whatever works.
17.4.2021 v0.4: I updated lines that makes restart easier when things go wrong. Script now searches if failed applications are still running and killing before restarting the whole thing.
10.5.2021 v0.5: Small fix for killing the applications correctly.

1 thought on “My audio setup bash script (0.5)”