mirror of https://github.com/aristocratos/bpytop
Fixed battery meter adaptation
parent
526d10146c
commit
4fd928e4a6
|
@ -1574,6 +1574,7 @@ class CpuBox(Box, SubBox):
|
||||||
battery_secs: int = 0
|
battery_secs: int = 0
|
||||||
battery_status: str = "Unknown"
|
battery_status: str = "Unknown"
|
||||||
old_battery_pos = 0
|
old_battery_pos = 0
|
||||||
|
old_battery_len = 0
|
||||||
clock_block: bool = True
|
clock_block: bool = True
|
||||||
Box.buffers.append(buffer)
|
Box.buffers.append(buffer)
|
||||||
|
|
||||||
|
@ -1697,10 +1698,11 @@ class CpuBox(Box, SubBox):
|
||||||
battery_symbol = "■"
|
battery_symbol = "■"
|
||||||
else:
|
else:
|
||||||
battery_symbol = "○"
|
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:
|
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))}'
|
out += f'{Mv.to(y-1, cls.old_battery_pos)}{THEME.cpu_box(Symbol.h_line*cls.old_battery_len)}'
|
||||||
cls.old_battery_pos = battery_pos
|
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}%'+
|
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}') +
|
("" 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)}')
|
f'{THEME.title}{battery_time}{Fx.ub}{THEME.cpu_box(Symbol.title_right)}')
|
||||||
|
|
Loading…
Reference in New Issue