linux_battery/examples/bat0.rs
2021-06-25 07:20:50 +02:00

12 lines
301 B
Rust

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);
}