12 lines
301 B
Rust
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);
|
||
|
}
|