@@ -12,27 +12,29 @@ bluetooth_print() {
12
12
device_info=$( bluetoothctl info " $device " )
13
13
14
14
if echo " $device_info " | grep -q " Connected: yes" ; then
15
- device_alias =$( echo " $device_info " | grep " Alias" | cut -d ' ' -f 2-)
16
- device_battery =$( echo " $device_info " | grep " Battery" | awk -F'[ ()]' ' {print $2 }' )
15
+ device_output =$( echo " $device_info " | grep " Alias" | cut -d ' ' -f 2-)
16
+ device_battery_percent =$( echo " $device_info " | grep " Battery Percentage " | awk -F'[ ()]' ' {print $2 }' )
17
17
18
- if [ -n "$device_battery " ]; then
19
- if [ "$device_battery " -gt 90 ]; then
20
- battery_icon ="#21 "
21
- elif [ "$device_battery " -gt 60 ]; then
22
- battery_icon ="#22 "
23
- elif [ "$device_battery " -gt 35 ]; then
24
- battery_icon ="#23"
25
- elif [ "$device_battery " -gt 10 ]; then
26
- battery_icon ="#24 "
18
+ if [ -n "$device_battery_percent " ]; then
19
+ if [ "$device_battery_percent " -gt 90 ]; then
20
+ device_battery_icon ="#25 "
21
+ elif [ "$device_battery_percent " -gt 60 ]; then
22
+ device_battery_icon ="#24 "
23
+ elif [ "$device_battery_percent " -gt 35 ]; then
24
+ device_battery_icon ="#23"
25
+ elif [ "$device_battery_percent " -gt 10 ]; then
26
+ device_battery_icon ="#22 "
27
27
else
28
- battery_icon ="#25 "
28
+ device_battery_icon ="#21 "
29
29
fi
30
- device_alias="${device_alias} $battery_icon $device_battery%"
30
+
31
+ device_output="$device_output $device_battery_icon $device_battery_percent%"
31
32
fi
33
+
32
34
if [ $counter -gt 0 ]; then
33
- printf ", %s" "$device_alias "
35
+ printf ", %s" "$device_output "
34
36
else
35
- printf " %s" "$device_alias "
37
+ printf " %s" "$device_output "
36
38
fi
37
39
38
40
counter=$((counter + 1))
0 commit comments