Fixed battery meter adaptation

pull/135/head
aristocratos 2020-09-20 18:27:10 +02:00
parent 526d10146c
commit 4fd928e4a6
1 changed files with 5 additions and 3 deletions

View File

@ -1574,6 +1574,7 @@ class CpuBox(Box, SubBox):
battery_secs: int = 0
battery_status: str = "Unknown"
old_battery_pos = 0
old_battery_len = 0
clock_block: bool = True
Box.buffers.append(buffer)
@ -1697,10 +1698,11 @@ class CpuBox(Box, SubBox):
battery_symbol = ""
else:
battery_symbol = ""
battery_pos = cls.width - len(f'{CONFIG.update_ms}') - 17 - (11 if cls.width >= 100 else 0) - len(battery_time) - len(f'{cls.battery_percent}')
battery_len: int = len(f'{CONFIG.update_ms}') + (11 if cls.width >= 100 else 0) + len(battery_time) + len(f'{cls.battery_percent}')
battery_pos = cls.width - battery_len - 17
if battery_pos != cls.old_battery_pos and cls.old_battery_pos > 0 and not cls.resized:
out += f'{Mv.to(y-1, cls.old_battery_pos)}{THEME.cpu_box(Symbol.h_line*(15 if cls.width >= 100 else 5))}'
cls.old_battery_pos = battery_pos
out += f'{Mv.to(y-1, cls.old_battery_pos)}{THEME.cpu_box(Symbol.h_line*cls.old_battery_len)}'
cls.old_battery_pos, cls.old_battery_len = battery_pos, battery_len
out += (f'{Mv.to(y-1, battery_pos)}{THEME.cpu_box(Symbol.title_left)}{Fx.b}{THEME.title}BAT{battery_symbol} {cls.battery_percent}%'+
("" if cls.width < 100 else f' {Fx.ub}{Meters.battery(cls.battery_percent)}{Fx.b}') +
f'{THEME.title}{battery_time}{Fx.ub}{THEME.cpu_box(Symbol.title_right)}')