Add different display units for systeminfo#541
Add different display units for systeminfo#541sulabi wants to merge 12 commits intoMalpenZibo:mainfrom
Conversation
| system.refresh_cpu_specifics(sysinfo::CpuRefreshKind::everything()); | ||
| system.refresh_cpu_all(); |
There was a problem hiding this comment.
the docs state that this function calls the same as before:
pub fn refresh_cpu_all(&mut self)
Calling this method is the same as calling
system.refresh_cpu_specifics(CpuRefreshKind::everything()).
use sysinfo::System;
let mut s = System::new_all();
s.refresh_cpu_all();| struct MemoryUsage { | ||
| percentage: u32, | ||
| fraction: String | ||
| } | ||
| struct CpuUsage { | ||
| percentage: u32, | ||
| frequency: f32 | ||
| } | ||
|
|
||
| struct Temperature { | ||
| celsius: Option<i32>, | ||
| fahrenheit: i32 | ||
| } |
There was a problem hiding this comment.
Why do we store both values? In my mind, we should store the "absolute" value and format that value to the desired format in the view method.
There was a problem hiding this comment.
there are two seperate methods that need this information, menu_view as well as view formatting these values again would be redundant
src/modules/system_info.rs
Outdated
| let memory_usage = ((system.total_memory() - system.available_memory()) as f32 | ||
| / system.total_memory() as f32 | ||
| * 100.) as u32; | ||
| let cpu_freq_mhz = system.cpus()[0].frequency() as f32; |
There was a problem hiding this comment.
Here, we only show the frequency of the first CPU. It's quite different from the counterpart global_cpu_usage.
There was a problem hiding this comment.
well yes, i should do the average frequency instead
src/config.rs
Outdated
| #[serde(default)] | ||
| pub alert_threshold: u32, | ||
|
|
||
| pub display_mode: CpuDisplayMode |
There was a problem hiding this comment.
Here maybe it's better to use Format as in the rest of the codebase. So pub format: CpuFormat
|
please also include storage/disk usage in total (human-readable), if possible. 😀 |
This pull request introduces different display units for system information values. The current ones I have added are:
these can be changed in the config, and the default display values are how it was before.
example config: