Fixed linux power_plugged status

This commit is contained in:
= 2024-08-17 17:48:53 -04:00
parent 69ca29e700
commit 72063ba9c6

View File

@ -117,7 +117,10 @@ class BatteryMonitor:
battery = psutil.sensors_battery()
if battery is not None:
battery_percentage = battery.percent / 100.0
if os.name == "nt":
battery_plugged = battery.power_plugged
else:
battery_plugged = int(open('/sys/class/power_supply/BAT1/current_now', 'r').read()) < 100000
return battery_percentage, battery_plugged