From 72063ba9c6cf144abadc4a97f0dea2df466a0f5c Mon Sep 17 00:00:00 2001 From: = <=> Date: Sat, 17 Aug 2024 17:48:53 -0400 Subject: [PATCH] Fixed linux power_plugged status --- monitors.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monitors.py b/monitors.py index ad24d9c..bfaff81 100644 --- a/monitors.py +++ b/monitors.py @@ -117,7 +117,10 @@ class BatteryMonitor: battery = psutil.sensors_battery() if battery is not None: battery_percentage = battery.percent / 100.0 - battery_plugged = battery.power_plugged + 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