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