Browse Source

Fix the case that "/sys/class/power_supply" is not existing

This fixes the execution on FreeBSD.
pull/135/head
Li-Wen Hsu 4 years ago
parent
commit
6643dc2605
No known key found for this signature in database
GPG Key ID: 8D7BCC7D012FD37E
  1. 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…
Cancel
Save