mirror of https://github.com/aristocratos/bpytop
Fix the case that "/sys/class/power_supply" is not existing
This fixes the execution on FreeBSD.pull/135/head
parent
45b103adb1
commit
6643dc2605
12
bpytop.py
12
bpytop.py
|
@ -1637,12 +1637,12 @@ class CpuBox(Box, SubBox):
|
|||
return False
|
||||
|
||||
if cls.battery_path == "":
|
||||
for directory in os.listdir("/sys/class/power_supply"):
|
||||
if directory.startswith('BAT') or 'battery' in directory.lower():
|
||||
cls.battery_path = f'/sys/class/power_supply/{directory}/'
|
||||
break
|
||||
else:
|
||||
cls.battery_path = None
|
||||
cls.battery_path = None
|
||||
if os.path.isdir("/sys/class/power_supply"):
|
||||
for directory in os.listdir("/sys/class/power_supply"):
|
||||
if directory.startswith('BAT') or 'battery' in directory.lower():
|
||||
cls.battery_path = f'/sys/class/power_supply/{directory}/'
|
||||
break
|
||||
|
||||
return_true: bool = False
|
||||
percent: int = ceil(getattr(psutil.sensors_battery(), "percent", 0))
|
||||
|
|
Loading…
Reference in New Issue