-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbt.sh
executable file
·30 lines (25 loc) · 1017 Bytes
/
bt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
if [[ -z $1 ]]; then
echo "No argument supplied. exiting..."
exit
fi
## get array of all known monitors
# mapfile -t DISP < <( xrandr --listmonitors | grep -v "^Monitors" | awk '{print $4}' )
# mapfile -t DISP < <( xrandr --current | grep " conn" | grep -v "^eDP" | awk '{print $1}' )
usage() { echo "Usage: $0 [a|a2dp|h|headset|r|reset]"; exit 1; }
num=0
while [[ -n $1 ]]; do
opt="$1"
case $opt in
a|a2dp ) SINK="a2dp_sink";;
h|headset ) SINK="headset_head_unit";;
r|reset ) RESET=1; FLIP=1 SINK=$(pactl info | grep "Default Sink" | awk -F. '{print $NF}');;
f|flip ) FLIP=1; SINK=$(pactl info | grep "Default Sink" | awk -F. '{print $NF}');;
*) usage;;
esac
shift
done
BLUEZCARD=$(pactl list cards short | egrep -o bluez.*[[:space:]])
[[ ${SINK} == "a2dp_sink" ]] && ALTSINK="headset_head_unit" || ALTSINK="a2dp_sink"
[[ ${FLIP} ]] && pactl set-card-profile $BLUEZCARD ${ALTSINK}
[[ ${RESET} ]] && pactl set-card-profile $BLUEZCARD ${SINK}