Improve connect_to_mx5.sh

This commit is contained in:
tosu 2024-02-01 00:21:58 +01:00
parent ec2d6b5949
commit 15777f7160
1 changed files with 21 additions and 5 deletions

View File

@ -1,9 +1,25 @@
#!/bin/sh
#!/bin/bash
set -euo pipefail
###################### STOP ###################
# Put device in pairing mode!!!
# MUST be uppercase
MX5_MAC="AC:80:0A:6D:F3:7B"
MX5_SINK="bluez_sink.AC_80_0A_6D_F3_7B.a2dp_sink"
MX3_MAC="14:3F:A6:A8:7F:CD"
DEVICE_MAC="${MX5_MAC}"
DEVICE_SINK="${MX5_SINK}"
function log () {
printf "\n\033[31m%s\033[m\n" "${@}" >/dev/tty
}
bluetoothctl power on \
&& bluetoothctl connect 14:3F:A6:A8:7F:CD
&& bluetoothctl connect "${DEVICE_MAC}"
sleep 3
bluetoothctl connect "${DEVICE_MAC}" ||
{ sleep 3; bluetoothctl connect "${DEVICE_MAC}"; }
bluetoothctl connect 14:3F:A6:A8:7F:CD ||
{ sleep 3; bluetoothctl connect 14:3F:A6:A8:7F:CD; }
pactl set-default-sink "${DEVICE_SINK}"