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"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "daemon"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "tui"
|
||||||
|
path = "src/tui/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rkyv = "0.8.15"
|
rkyv = {version = "0.8.15"}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use crate::data::{BatteryMutable, BatteryStatic};
|
|||||||
pub struct Battery {
|
pub struct Battery {
|
||||||
charge: i64,
|
charge: i64,
|
||||||
total_capacity: i64,
|
total_capacity: i64,
|
||||||
|
drain: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -28,12 +29,15 @@ impl Battery {
|
|||||||
Ok(Battery {
|
Ok(Battery {
|
||||||
charge: 0,
|
charge: 0,
|
||||||
total_capacity: energy_full.parse().unwrap(),
|
total_capacity: energy_full.parse().unwrap(),
|
||||||
|
drain: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn update(&mut self) -> Result<(), Battery_Error> {
|
pub fn update(&mut self) -> Result<(), Battery_Error> {
|
||||||
let charge = fs::read_to_string("/sys/class/power_supply/BAT0/energy_now").unwrap();
|
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.charge = charge.trim().parse().unwrap();
|
||||||
|
self.drain = drain.trim().parse().unwrap();
|
||||||
|
|
||||||
Ok(())
|
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