From 2ed87535fc547655eb60298579636aa2b5a20e91 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sun, 7 Feb 2021 20:46:20 +0100 Subject: [PATCH] Added script to switch between bt output --- bin/btswitch.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 bin/btswitch.sh diff --git a/bin/btswitch.sh b/bin/btswitch.sh new file mode 100755 index 0000000..6bafe5d --- /dev/null +++ b/bin/btswitch.sh @@ -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 " + 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