Skip to content

Commit

Permalink
Fix print and add icon when collor is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rodoufu authored Jan 8, 2025
1 parent fd62f4b commit 2cb08c1
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions contrib/bluetooth_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,24 @@ def find_and_clean_up(info, to_find):
icon = icon_name_symbol.get(icon)

if is_connected and battery is not None:
batery_text = f"{battery:.0f}%"
battery_text = f"{battery:.0f}%"
if icon:
batery_text = f"{icon} {batery_text}"
battery_text = f"{icon} {battery_text}"
else:
batery_text = f"{device_name} {batery_text}"
battery_text = f"{device_name} {battery_text}"

if not ignore_colors:
if battery_red <= battery <= battery_yellow:
batery_text = bcolors.WARNING.colored(batery_text)
elif battery < battery_red:
batery_text = bcolors.FAIL.colored(batery_text)
if battery_red <= battery <= battery_yellow:
if ignore_colors:
battery_text = f"{battery_text} 󰥄"
else:
battery_text = bcolors.WARNING.colored(battery_text)
elif battery < battery_red:
if ignore_colors:
battery_text = f"{battery_text} 󰤾"
else:
battery_text = bcolors.FAIL.colored(battery_text)

line.append(batery_text)
line.append(battery_text)

return line

Expand Down Expand Up @@ -179,6 +184,4 @@ def read_line():
},
)
# and echo back new encoded json
print(prefix + json.dumps(j))
# print_line(prefix + json.dumps(j))
sys.stdout.flush()
print_line(prefix + json.dumps(j))

0 comments on commit 2cb08c1

Please sign in to comment.