aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts/status/bluetooth-status
blob: a84ede3d82381615453c0b7c6f77e7eb57f696d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env sh

devices=$(bluetoothctl devices Connected | grep -oE '([0-9A-Fa-f:]{17})')

if [ -z "$devices" ]
then
    echo ""
else
    acc=""

    for mac in $devices
    do
        name=$(bluetoothctl info $mac | grep "Alias" | sed 's/.*Alias: //')
        battery=$(bluetoothctl info $mac | grep "Battery Percentage" | sed 's/.*(//;s/)//')
        acc="$acc $name"
        if [ "$battery" ]
        then
            acc="$acc ($battery%)"
        fi
    done

    echo "$acc"
fi