diff options
| author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-10-29 00:18:41 +0000 | 
|---|---|---|
| committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-10-29 00:31:21 +0000 | 
| commit | 8b535437f660087465b7271b1df065f5e6f59283 (patch) | |
| tree | fd6a2950058925dbfae1c1cb9eba54cf04d9d894 /Scripts/.local/scripts/status/bluetooth-status | |
| parent | 11b2f049fef2a2f41272d481952b3e1f8a217cd7 (diff) | |
| download | dotfiles-8b535437f660087465b7271b1df065f5e6f59283.tar.gz dotfiles-8b535437f660087465b7271b1df065f5e6f59283.tar.bz2 dotfiles-8b535437f660087465b7271b1df065f5e6f59283.zip | |
Extend bluetooth-status to present the status of multiple devices
Diffstat (limited to 'Scripts/.local/scripts/status/bluetooth-status')
| -rwxr-xr-x | Scripts/.local/scripts/status/bluetooth-status | 26 | 
1 files changed, 17 insertions, 9 deletions
| diff --git a/Scripts/.local/scripts/status/bluetooth-status b/Scripts/.local/scripts/status/bluetooth-status index 35c550a..a84ede3 100755 --- a/Scripts/.local/scripts/status/bluetooth-status +++ b/Scripts/.local/scripts/status/bluetooth-status @@ -1,15 +1,23 @@  #!/usr/bin/env sh -name=$(bluetoothctl info | grep "Alias" | sed 's/.*Alias: //') -battery=$(bluetoothctl info | grep "Battery Percentage" | sed 's/.*(//;s/)//') -if [ ! "$name" ] +devices=$(bluetoothctl devices Connected | grep -oE '([0-9A-Fa-f:]{17})') + +if [ -z "$devices" ]  then      echo ""  else -    echo -n "" $name; -    if [ "$battery" ] -    then -        echo -n " ($battery%)" -    fi -    echo "" +    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 | 
