diff --git a/bluetooth.sh b/bluetooth.sh index fea6d95..47bbf60 100755 --- a/bluetooth.sh +++ b/bluetooth.sh @@ -1,12 +1,14 @@ -#!/bin/sh -if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] -then +#!/bin/bash + +# Check if Bluetooth is powered on +if ! bluetoothctl show | grep -q "Powered: yes"; then echo "%{F#66ffffff}" else - if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ] - then - echo "" + # Check if any Bluetooth device is connected + if bluetoothctl info | grep -q 'Connected: yes'; then + DEVICE=$(bluetoothctl info | awk -F': ' '/Alias:/ { print $2 }') + echo "%{F#2193ff} $DEVICE " + else + echo "" fi - echo "%{F#2193ff}" -fi - +fi \ No newline at end of file