svartalf / rust-battery

Rust crate providing cross-platform information about the notebook batteries.
https://crates.io/crates/battery
Apache License 2.0
354 stars 40 forks source link

Battery State Unknown when battery is not charging but plugged into AC power. #99

Open trollLemon opened 11 months ago

trollLemon commented 11 months ago

Before I begin, I want to thank the maintainers of this crate, as it helped a lot in my Screen Brightness daemon, where I needed battery info.

On Linux laptops, software like TLP (https://linrunner.de/tlp/) can configure the battery to stop charging at a certain threshold while plugged in. I used TLP on my ArchLinux laptop and noticed that battery.state() will return "unknown" as a state when the battery is on AC power but was not charging.

I looked at my battery's status file and found that when the battery is on AC power but not charging, the status file will read "Not Charging."

I can work on a PR that adds support for the "Not charging" state. I would need to add a new value to the State enum and add formatting for the new state.