From 2cb08c161526b86eb4b234423c4f56b9ea669508 Mon Sep 17 00:00:00 2001 From: Rodolfo P A <6721075+rodoufu@users.noreply.github.com> Date: Wed, 8 Jan 2025 18:07:38 -0300 Subject: [PATCH] Fix print and add icon when collor is disabled --- contrib/bluetooth_battery.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/contrib/bluetooth_battery.py b/contrib/bluetooth_battery.py index f51b69c7..9c3e318f 100644 --- a/contrib/bluetooth_battery.py +++ b/contrib/bluetooth_battery.py @@ -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 @@ -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))