mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-22 08:38:33 +02:00
feat(bar): initial commit
This commit is contained in:
26
komorebi-bar/src/memory.rs
Normal file
26
komorebi-bar/src/memory.rs
Normal 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)]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user