From b7341caa4d50fa761001acc2988d90ea61829f11 Mon Sep 17 00:00:00 2001 From: vasilito Date: Sun, 28 Jun 2026 18:56:05 +0300 Subject: [PATCH] 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 --- .../system/redbear-power/source/src/main.rs | 2 +- .../system/redbear-power/source/src/render.rs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/local/recipes/system/redbear-power/source/src/main.rs b/local/recipes/system/redbear-power/source/src/main.rs index 657100d0e2..91f0a17eae 100644 --- a/local/recipes/system/redbear-power/source/src/main.rs +++ b/local/recipes/system/redbear-power/source/src/main.rs @@ -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, ); diff --git a/local/recipes/system/redbear-power/source/src/render.rs b/local/recipes/system/redbear-power/source/src/render.rs index 632ae2f430..a91379a4d8 100644 --- a/local/recipes/system/redbear-power/source/src/render.rs +++ b/local/recipes/system/redbear-power/source/src/render.rs @@ -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, focused: bool, + pkg_power_w: Option, + 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, );