Added script to switch between bt output

This commit is contained in:
dbroqua 2021-02-07 20:46:20 +01:00
parent 5c20ad0dab
commit 2ed87535fc

39
bin/btswitch.sh Executable file
View file

@ -0,0 +1,39 @@
#! /bin/bash
HEADPHONE="88:D0:39:7D:6A:70"
SPEAKERS="EC:81:93:94:92:73"
if [ -z "$1" ]; then
echo "Missing profil"
echo "example: btswitch.sh <headphone|speakers>"
exit 1
fi
case ${1} in
headphone)
bluetoothctl disconnect ${SPEAKERS}
bluetoothctl connect ${HEADPHONE}
# INFO: Dirty
sleep 5
;;
speakers)
bluetoothctl disconnect ${HEADPHONE}
bluetoothctl connect ${SPEAKERS}
;;
*)
echo "Unknown mode"
exit 1
esac
OUTPUTID=`pactl list short sinks|grep bluez|cut -f 1`
echo "Set Bluetooth as default output"
pacmd set-default-sink ${OUTPUTID}
echo "Move streams to default output"
pactl list short sink-inputs|while read stream; do
streamId=$(echo $stream|cut '-d ' -f1)
echo "moving stream $streamId"
pactl move-sink-input "$streamId" "${OUTPUTID}"
done