summaryrefslogtreecommitdiff
path: root/.config/i3/connect-speakers.sh
blob: 0bc1d2bc1943c3a040a86a30f987414b27a814da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

MAC="7C:96:D2:6E:79:CA"

powered() {
    echo "show" | bluetoothctl | grep "Powered" | cut -d " " -f 2
}

connected() {
    echo "info ${MAC}" | bluetoothctl | grep "Connected" | cut -d " " -f 2
}

echo "trust ${MAC}" | bluetoothctl
while [ $(connected) = no ]
do
    sleep 1
    if [ $(powered) = yes ] && [ $(connected) = no ]; then
        echo "connect ${MAC}" | bluetoothctl
        sleep 5
    fi
done

echo "Connected"