From 7775921a3da8a5a6849eaa895e6b91673f8d97ab Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 25 Sep 2024 22:01:51 -0400 Subject: [PATCH] Improved charging status detection in linux --- monitors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monitors.py b/monitors.py index d5f93fa..cb6658b 100644 --- a/monitors.py +++ b/monitors.py @@ -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