Improved charging status detection in linux

This commit is contained in:
= 2024-09-25 22:01:51 -04:00
parent 6db1568718
commit 7775921a3d

View File

@ -120,7 +120,8 @@ class BatteryMonitor:
if os.name == "nt":
battery_plugged = battery.power_plugged
else:
battery_plugged = int(open('/sys/class/power_supply/BAT1/current_now', 'r').read()) < 100000
bat_status = open('/sys/class/power_supply/BAT1/status', 'r').read().strip()
battery_plugged = (bat_status == 'Charging')
return battery_percentage, battery_plugged