You are not logged in.
For some reason, auto-switching audio devices to bluetooth on connecting BT phones randomly stopped working for me anymore since some package updates.
So I made a little workaround script that is loaded on login, which I wanted to share if anyone has the same problem and might find it useful. I guess it's very simple and everyone can make it on his own but anyway. So if you have any suggestions for improving it, I'm glad to hear.
It depends on bluez as bt daemon and it checks every 3 seconds for active audio sources and reroutes them to BT if there is a BT sink (headphones/speaker..) connected.
If no bluetooth sink is available at all, continues checking for one every 5 seconds:
#!/bin/bash
# Move all apps' audio output to bluetooth
while true; do
# Check for bluez sink
BTSINK=`pactl list short sinks | grep -o "bluez_sink[._a-zA-Z0-9]*" | head -n 1`
if [ -z $BTSINK ]; then
#echo "Error 1: No bluez_sink found."
#exit 1
sleep 5
continue
fi
# Collect all apps that currently output audio into a sink, print each app's sink-input-index into a file for iterating over
pactl list short sink-inputs | grep -o "^[0-9]*" > /tmp/__sink-inputs
while IFS= read -r line
do
# Redirect each app's output, aka input to any audio sink, to the bluetooth sink
pactl move-sink-input $line $BTSINK
done < /tmp/__sink-inputs
rm -f /tmp/__sink-inputs
sleep 3
done
Last edited by millus (2022-04-04 21:22:29)
Offline