Skip to content

Add different display units for systeminfo#541

Open
sulabi wants to merge 12 commits intoMalpenZibo:mainfrom
sulabi:system-info-display
Open

Add different display units for systeminfo#541
sulabi wants to merge 12 commits intoMalpenZibo:mainfrom
sulabi:system-info-display

Conversation

@sulabi
Copy link
Copy Markdown

@sulabi sulabi commented Mar 22, 2026

This pull request introduces different display units for system information values. The current ones I have added are:

  • Memory: "Percentage" (default), "Fraction"
  • Cpu: "Percentage" (default), "Frequency"
  • Temperature: "Celsius" (default), "Fahrenheit"
  • MemorySwap: Uses the same display value as memory

these can be changed in the config, and the default display values are how it was before.

example config:

[system_info.memory]
display_mode = "Percentage" # or "Fraction"

[system_info.cpu]
display_mode = "Percentage" # or "Frequency"

[system_info.temperature]
display_mode = "Fahrenheit" # or "Celsius"

@sulabi sulabi marked this pull request as ready for review March 22, 2026 22:29
Comment on lines -40 to +54
system.refresh_cpu_specifics(sysinfo::CpuRefreshKind::everything());
system.refresh_cpu_all();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Comment on lines +23 to +35
struct MemoryUsage {
percentage: u32,
fraction: String
}
struct CpuUsage {
percentage: u32,
frequency: f32
}

struct Temperature {
celsius: Option<i32>,
fahrenheit: i32
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two seperate methods that need this information, menu_view as well as view formatting these values again would be redundant

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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we only show the frequency of the first CPU. It's quite different from the counterpart global_cpu_usage.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well yes, i should do the average frequency instead

src/config.rs Outdated
#[serde(default)]
pub alert_threshold: u32,

pub display_mode: CpuDisplayMode
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here maybe it's better to use Format as in the rest of the codebase. So pub format: CpuFormat

@juvilius
Copy link
Copy Markdown

juvilius commented Apr 2, 2026

please also include storage/disk usage in total (human-readable), if possible. 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants