#!/bin/bash # # ~/.local/bin/btswitch # # wait a second this is too fast for udev sleep 1 btdev="$(pactl list sinks|grep Name|grep 'bluez5.a2dp.sink'|sed 's/Name: //'|sed 's/\s//')" if [ -n "$btdev" ]; then echo "Found bluetooth device: $btdev" else echo "Could not find bluetooth device, exiting..." exit 1 fi echo "Setting default sink to the found bluetooth device..." echo "Running pactl set-default-sink $btdev" pactl set-default-sink "$btdev" echo "Setting default volume of sink to 26%" pactl set-sink-volume @DEFAULT_SINK@ 26% echo "Moving all sink inputs to the default sink..." for i in $(pactl list sink-inputs|grep 'Sink Input'|sed 's/Sink Input #//'); do echo "Moving all sink input $i to the default sink..." pactl move-sink-input $i @DEFAULT_SINK@ done