24 lines
493 B
Bash
Executable File
24 lines
493 B
Bash
Executable File
#!/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
|