svartalf / rust-battery

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

Watch for updates #34

Closed Gerschtli closed 5 years ago

Gerschtli commented 5 years ago

Hello everyone, nice project you created here!

Is it planned to provide a watcher-like functionality? For my package dwm-status I build a watcher based on dbus events, maybe you are interested in adding a similar API method.

svartalf commented 5 years ago

Hey, @Gerschtli!

There are no plans to make anything like this right now, as there is no such a notification mechanism for all platforms currently supported (note that Linux implementation is using sysfs instead of uevent+dbus).

It is possible to make this "watcher" in a polling manner and just re-read all data each n time, but it looks like a easy task to implement by yourself (Manager::refresh could help with that).

Gerschtli commented 5 years ago

Ah okay, the polling way is not an acceptable way for my project because of its ineffeciency and inaccuracy. But thank you for your quick response!