Last active
June 26, 2023 01:02
-
-
Save Ghostbird/6f810a03f7c07dae7b2389082accf6ed to your computer and use it in GitHub Desktop.
Add extra pulseaudio - jack bridge connections to allow jack routing for pulseaudio applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sources=(telegram zoom teams discord extra) | |
sinks=(telegram kodi zoom teams discord extra) | |
startTime=$(date +%s) | |
function capitalise() { | |
echo $1 | sed -e "s/\b\(.\)/\u\1/g" | |
} | |
function start() { | |
for sink in "${sinks[@]}" | |
do | |
# echo $(capitalise ${sink}) Sink | |
pactl load-module module-jack-sink client_name="'$(capitalise ${sink})'" sink_name="${sink}" sink_properties="starttime=$startTime" connect=no > /dev/null | |
done | |
for source in "${sources[@]}" | |
do | |
# echo $(capitalise ${source}) Source | |
pactl load-module module-jack-source client_name="'$(capitalise ${source}) '" source_name="${source}" source_properties="starttime=$startTime" connect=no > /dev/null | |
done | |
echo "Added extra PulseAudio connections" | |
} | |
function stop() { | |
pactl list modules short | grep $startTime | cut -f1 | xargs -n 1 pactl unload-module | |
echo "Removed extra PulseAudio connections" | |
} | |
# Kill sleep on any of these signals | |
trap '[[ $pid ]] && kill $pid' TERM INT HUP QUIT | |
start | |
sleep infinity & # Run infinite sleep in background | |
pid=$! # Save PID of sleep program | |
wait $pid # Wait for sleep to be killed by the trap | |
stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ran into an issue where I'd get a lot of
Failure: Module initialization failed
lines when trying to run the script.In
sudo journalctl -f
I saw that this was becausepulseaudio
was hitting the maximum number of files that it was allowed to keep open.The solution was:
In the section
[Service]
add al line that says:Note: You can use a higher number than 1024 files if necessary.
Afterwards reload the file and restart pulseaudio:
DON'T run these commands with
sudo
. PulseAudio is a per-user service, hence the--user
flag.