From 05eaf66916e41ec9acf51b1d8e46933a515109f9 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Thu, 17 Feb 2022 13:42:04 +0100 Subject: [PATCH] Polybar's bluetooth script hanging problem fixed --- polybar/.config/polybar/scripts/bluetooth.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/polybar/.config/polybar/scripts/bluetooth.sh b/polybar/.config/polybar/scripts/bluetooth.sh index 58d63e3..5c90b6e 100755 --- a/polybar/.config/polybar/scripts/bluetooth.sh +++ b/polybar/.config/polybar/scripts/bluetooth.sh @@ -3,17 +3,18 @@ case $1 in "") - if [ "$(bluetoothctl show | grep "Powered: yes" | wc -c)" -eq 0 ]; then - printf "%s\n" "%{F#66ffffff}" - elif [ "$(printf "%s\n" info | bluetoothctl | grep 'Device' | wc -c)" -eq 0 ]; then - printf "%s\n" "" - printf "%s\n" "%{F#2193ff}" + bt_color="" + if bluetoothctl show | grep -q "Powered: no"; then + bt_color="%{F#66ffffff}" + elif bluetoothctl info | grep -q "Device"; then + bt_color="%{F#2193ff}" else - printf "%s\n" "%{F#2193ff}" + : fi + printf "%s%s\n" "$bt_color" "" ;; "--toggle") - if [ "$(bluetoothctl show | grep "Powered: yes" | wc -c)" -eq 0 ]; then + if bluetoothctl show | grep -q "Powered: no"; then bluetoothctl power on else bluetoothctl power off