linux_battery/examples/bat0.rs

12 lines
301 B
Rust
Raw Permalink Normal View History

2021-06-25 05:07:51 +00:00
use linux_battery;
fn main() {
let mut battery = linux_battery::Battery::new("BAT0");
let mut msg = format!("Status: {}", battery.state());
match battery.capacity() {
Some(cap) => msg = format!("{}\tCapacity: {} %", msg, cap),
None => {},
}
println!("{}", msg);
}