From 8b535437f660087465b7271b1df065f5e6f59283 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 29 Oct 2025 00:18:41 +0000 Subject: Extend bluetooth-status to present the status of multiple devices --- Scripts/.local/scripts/status/bluetooth-status | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'Scripts') 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 -- cgit v1.2.3-13-gbd6f