redbear-power: restore PkgW column with compact labels
- Per-CPU table: PkgW column shows 'root' (needs sudo), 'n/a' (unsupported), '...' (sampling), or wattage when RAPL working - Header shows full rapl_status message for context
This commit is contained in:
@@ -344,7 +344,7 @@ fn main() -> io::Result<()> {
|
||||
match app.current_tab {
|
||||
TabId::PerCpu => {
|
||||
f.render_stateful_widget(
|
||||
render_cpu_table(&app.cpus, app.expanded_cpu, focused_panel == 1),
|
||||
render_cpu_table(&app.cpus, app.expanded_cpu, focused_panel == 1, app.pkg_power_w, &app.rapl_status),
|
||||
body_area,
|
||||
&mut app.table_state,
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! │ MSR / Daemons / │ │ ... │
|
||||
//! └─────────────────────┘ └────────────┘
|
||||
//! ┌─ Per-CPU ───────────────┐
|
||||
//! │ CPU Freq Temp │
|
||||
//! │ CPU Freq PkgW Temp │
|
||||
//! │ 0 2400 15.0 72▏▌·· │
|
||||
//! │ 1 2400 15.0 70▏▎·· │
|
||||
//! └────────────────────────┘
|
||||
@@ -1403,10 +1403,13 @@ pub fn render_cpu_table<'a>(
|
||||
cpus: &'a [CpuRow],
|
||||
expanded_cpu: Option<u32>,
|
||||
focused: bool,
|
||||
pkg_power_w: Option<f64>,
|
||||
rapl_status: &'a str,
|
||||
) -> Table<'a> {
|
||||
let header = Row::new(vec![
|
||||
"CPU".set_style(theme::LABEL),
|
||||
"Freq/MHz".set_style(theme::LABEL),
|
||||
"PkgW".set_style(theme::LABEL),
|
||||
"Temp°C bar".set_style(theme::LABEL),
|
||||
"P-state".set_style(theme::LABEL),
|
||||
"State".set_style(theme::LABEL),
|
||||
@@ -1463,6 +1466,15 @@ pub fn render_cpu_table<'a>(
|
||||
Row::new(vec![
|
||||
Cell::from(format!("{}{}", cpuid::core_type_label(cpu.core_type), cpu.id).set_style(theme::VALUE)),
|
||||
Cell::from(freq.set_style(theme::VALUE)),
|
||||
Cell::from(pkg_power_w
|
||||
.map(|w| format!("{w:.1}"))
|
||||
.unwrap_or_else(|| match rapl_status {
|
||||
s if s.contains("run as root") => "root".into(),
|
||||
s if s.contains("unsupported") => "n/a".into(),
|
||||
s if s.contains("sampling") => "...".into(),
|
||||
_ => "n/a".into(),
|
||||
})
|
||||
.set_style(if pkg_power_w.is_some() { theme::VALUE } else { theme::VALUE_OFF })),
|
||||
temp_cell,
|
||||
Cell::from(pstate.set_style(theme::VALUE)),
|
||||
Cell::from(cpu.state_label().set_style(theme::VALUE)),
|
||||
@@ -1659,7 +1671,7 @@ pub fn snapshot(app: &App, width: u16, height: u16) -> String {
|
||||
);
|
||||
f.render_widget(render_header(app, true), header_area);
|
||||
f.render_stateful_widget(
|
||||
render_cpu_table(&app.cpus, app.expanded_cpu, true),
|
||||
render_cpu_table(&app.cpus, app.expanded_cpu, true, app.pkg_power_w, &app.rapl_status),
|
||||
table_area,
|
||||
&mut state,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user