Skip to content

Commit 777aca1

Browse files
committed
system-bluetooth-bluetoothctl: reorganize vars
1 parent 9a8af3a commit 777aca1

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

polybar-scripts/system-bluetooth-bluetoothctl/system-bluetooth-bluetoothctl.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,29 @@ bluetooth_print() {
1212
device_info=$(bluetoothctl info "$device")
1313

1414
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}')
1717
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"
2727
else
28-
battery_icon="#25"
28+
device_battery_icon="#21"
2929
fi
30-
device_alias="${device_alias} $battery_icon $device_battery%"
30+
31+
device_output="$device_output $device_battery_icon $device_battery_percent%"
3132
fi
33+
3234
if [ $counter -gt 0 ]; then
33-
printf ", %s" "$device_alias"
35+
printf ", %s" "$device_output"
3436
else
35-
printf " %s" "$device_alias"
37+
printf " %s" "$device_output"
3638
fi
3739
3840
counter=$((counter + 1))

0 commit comments

Comments
 (0)