init tui and more battery stats
This commit is contained in:
10
Cargo.toml
10
Cargo.toml
@@ -3,5 +3,13 @@ name = "battery_logger"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "daemon"
|
||||
path = "src/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "tui"
|
||||
path = "src/tui/main.rs"
|
||||
|
||||
[dependencies]
|
||||
rkyv = "0.8.15"
|
||||
rkyv = {version = "0.8.15"}
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::data::{BatteryMutable, BatteryStatic};
|
||||
pub struct Battery {
|
||||
charge: i64,
|
||||
total_capacity: i64,
|
||||
drain: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -28,12 +29,15 @@ impl Battery {
|
||||
Ok(Battery {
|
||||
charge: 0,
|
||||
total_capacity: energy_full.parse().unwrap(),
|
||||
drain: 0,
|
||||
})
|
||||
}
|
||||
pub fn update(&mut self) -> Result<(), Battery_Error> {
|
||||
let charge = fs::read_to_string("/sys/class/power_supply/BAT0/energy_now").unwrap();
|
||||
let drain = fs::read_to_string("/sys/class/power_supply/BAT0/power_now").unwrap();
|
||||
|
||||
self.charge = charge.trim().parse().unwrap();
|
||||
self.drain = drain.trim().parse().unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
3
src/tui/main.rs
Normal file
3
src/tui/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user