aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts/status/bluetooth-status
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-11-04 16:37:44 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-11-04 16:37:44 +0000
commit0d374a5f82b88177d2fdaf35d9c28080a8f35494 (patch)
tree88f4e7c97f48884080d07d64936e180fbd493a0c /Scripts/.local/scripts/status/bluetooth-status
parent0f667e4d76857f582048a6560320c5515749242d (diff)
downloaddotfiles-0d374a5f82b88177d2fdaf35d9c28080a8f35494.tar.gz
dotfiles-0d374a5f82b88177d2fdaf35d9c28080a8f35494.tar.bz2
dotfiles-0d374a5f82b88177d2fdaf35d9c28080a8f35494.zip
awk refactor of my scripts
awk is OP man - so easy to use and does a bunch of stuff all at once without having to rely on multiple pipes. It comes with essentially every distribution so you'll always have access to it.
Diffstat (limited to 'Scripts/.local/scripts/status/bluetooth-status')
-rwxr-xr-xScripts/.local/scripts/status/bluetooth-status22
1 files changed, 12 insertions, 10 deletions
diff --git a/Scripts/.local/scripts/status/bluetooth-status b/Scripts/.local/scripts/status/bluetooth-status
index a84ede3..0eadb4e 100755
--- a/Scripts/.local/scripts/status/bluetooth-status
+++ b/Scripts/.local/scripts/status/bluetooth-status
@@ -1,23 +1,25 @@
#!/usr/bin/env sh
-devices=$(bluetoothctl devices Connected | grep -oE '([0-9A-Fa-f:]{17})')
+devices=$(bluetoothctl devices Connected | awk '{print $2}')
if [ -z "$devices" ]
then
- echo ""
+ echo ''
else
- acc=""
-
+ sep=''
+ printf ' '
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"
+ 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
- acc="$acc ($battery%)"
+ printf " $battery%%"
fi
+ printf ">"
+ sep=" "
done
-
- echo "$acc"
+ printf "\n"
fi