2022-03-10 19:56:00 +01:00
|
|
|
#!/bin/bash
|
2022-03-10 19:46:05 +01:00
|
|
|
|
2022-03-10 19:56:00 +01:00
|
|
|
##
|
|
|
|
# Create virtual sinks for use it on Twitch VOD Track.
|
|
|
|
#
|
|
|
|
# @author kj
|
|
|
|
# @website http://kj2.me
|
|
|
|
# @licence MIT
|
|
|
|
##
|
2022-03-10 19:46:05 +01:00
|
|
|
|
2022-03-10 19:56:00 +01:00
|
|
|
AUDIOOUTPUTDEVICE=bluez_output.00_25_DB_69_D3_0B.a2dp-sink
|
2022-03-10 19:46:05 +01:00
|
|
|
|
2022-03-10 19:56:00 +01:00
|
|
|
function startSinks() {
|
|
|
|
if [ -f "sinks.pid" ]; then
|
|
|
|
echo "Se ha encontrado el archivo de configuración de dispositivos virtuales previos."
|
|
|
|
stopSinks
|
|
|
|
fi
|
|
|
|
|
|
|
|
AUDIOOUTPUTDEVICE=$1
|
|
|
|
|
|
|
|
echo "Creando los nuevos dispositvos virtuales..."
|
|
|
|
pw-loopback --capture-props='media.class=Audio/Sink node.name=Music_Sink audio.position=[FL FR]' --playback-props='audio.position=[FR FL] node.target="'$AUDIOOUTPUTDEVICE'"' > /dev/null 2>&1 &
|
|
|
|
Main_PID=$!
|
|
|
|
pw-loopback --capture-props='media.class=Audio/Sink node.name=Main_Sink audio.position=[FL FR]' --playback-props='audio.position=[FR FL] node.target="'$AUDIOOUTPUTDEVICE'"' > /dev/null 2>&1 &
|
|
|
|
Music_PID=$!
|
|
|
|
|
|
|
|
echo $Main_PID >> sinks.pid
|
|
|
|
echo $Music_PID >> sinks.pid
|
|
|
|
|
|
|
|
echo "Las dispositivos de audio virtuales han sido creados :)."
|
|
|
|
}
|
|
|
|
|
|
|
|
function stopSinks() {
|
|
|
|
if [ -f "sinks.pid" ]; then
|
|
|
|
echo "Deteniendo los dispositivos virtuales..."
|
|
|
|
while read -r pid; do
|
|
|
|
kill -9 $pid
|
|
|
|
done < sinks.pid
|
|
|
|
rm sinks.pid
|
|
|
|
echo "Dispositivos virtuales detenidos."
|
|
|
|
else
|
|
|
|
echo "No se ha encontrado el archivo de configuración, no hay nada para detener."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" == "start" ]; then
|
|
|
|
startSinks $AUDIOOUTPUTDEVICE
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" == "stop" ]; then
|
|
|
|
stopSinks
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" == "list" ]; then
|
|
|
|
pactl list short sinks
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Modo de uso: $(basename $0) [start|stop|list]"
|