summaryrefslogtreecommitdiff
path: root/external/plyer/platforms/win/battery.py
diff options
context:
space:
mode:
Diffstat (limited to 'external/plyer/platforms/win/battery.py')
-rw-r--r--external/plyer/platforms/win/battery.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/external/plyer/platforms/win/battery.py b/external/plyer/platforms/win/battery.py
new file mode 100644
index 0000000..04006f8
--- /dev/null
+++ b/external/plyer/platforms/win/battery.py
@@ -0,0 +1,21 @@
+from plyer.platforms.win.libs.batterystatus import battery_status
+from plyer.facades import Battery
+
+
+class WinBattery(Battery):
+ def _get_state(self):
+ status = {"isCharging": None, "percentage": None}
+
+ query = battery_status()
+
+ if (not query):
+ return status
+
+ status["isCharging"] = query["BatteryFlag"] == 8
+ status["percentage"] = query["BatteryLifePercent"]
+
+ return status
+
+
+def instance():
+ return WinBattery()