Skip to content

Commit

Permalink
Fix the case that "/sys/class/power_supply" is not existing
Browse files Browse the repository at this point in the history
This fixes the execution on FreeBSD.
  • Loading branch information
lwhsu committed Sep 28, 2020
1 parent 45b103a commit 6643dc2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bpytop.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,12 +1637,12 @@ def battery_activity(cls) -> bool:
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))
Expand Down

0 comments on commit 6643dc2

Please sign in to comment.