feat(bar): initial commit

This commit is contained in:
LGUG2Z
2024-07-25 17:30:01 -07:00
parent c06d9afa3b
commit e5fa03c33c
9 changed files with 464 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
use crate::widget::BarWidget;
use sysinfo::RefreshKind;
use sysinfo::System;
pub struct Memory {
system: System,
}
impl Default for Memory {
fn default() -> Self {
Self {
system: System::new_with_specifics(
RefreshKind::default().without_cpu().without_processes(),
),
}
}
}
impl BarWidget for Memory {
fn output(&mut self) -> Vec<String> {
self.system.refresh_memory();
let used = self.system.used_memory();
let total = self.system.total_memory();
vec![format!("RAM: {}%", (used * 100) / total)]
}
}