aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts/status/bluetooth-status
blob: 0eadb4eeb2423e1b5d7ff49d539bc01211b26b1b (plain)
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
#!/usr/bin/env sh

devices=$(bluetoothctl devices Connected | awk '{print $2}')

if [ -z "$devices" ]
then
    echo ''
else
    sep=''
    printf ' '
    for mac in $devices
    do
        name=$(bluetoothctl info $mac | awk -F ': ' '/Alias/ { print $2 }')
        battery=$(bluetoothctl info $mac | awk -F '[()]' '/Battery Percentage/ { print $2 }')

        printf "$sep<$name"
        if [ "$battery" ]
        then
            printf " $battery%%"
        fi
        printf ">"
        sep=" "
    done
    printf "\n"
fi