diff --git a/local/recipes/system/redbear-power/source/src/render.rs b/local/recipes/system/redbear-power/source/src/render.rs index 5439662fa5..ba667b0034 100644 --- a/local/recipes/system/redbear-power/source/src/render.rs +++ b/local/recipes/system/redbear-power/source/src/render.rs @@ -1818,8 +1818,26 @@ pub fn render_cpu_table<'a>( let rows: Vec = cpus .iter() .map(|cpu| { + let freq_mhz = cpu.freq_khz / 1000; + let freq_style = if !cpu.pstates.is_empty() { + let max_f = cpu.pstates.first().map(|p| p.freq_khz).unwrap_or(0) / 1000; + let min_f = cpu.pstates.last().map(|p| p.freq_khz).unwrap_or(0) / 1000; + if max_f > min_f && freq_mhz > 0 { + let pct = (freq_mhz - min_f) as f64 * 100.0 / (max_f - min_f) as f64; + match pct as u32 { + p if p >= 85 => theme::VALUE_HOT, + p if p >= 50 => theme::VALUE_WARM, + p if p <= 15 => Style::new().dark_gray(), + _ => theme::VALUE, + } + } else { + theme::VALUE + } + } else { + theme::VALUE + }; let freq = if cpu.freq_khz > 0 { - format!("{}", cpu.freq_khz / 1000) + format!("{}", freq_mhz) } else { "?".into() }; @@ -1879,7 +1897,7 @@ pub fn render_cpu_table<'a>( format!("{}{}", cpuid::core_type_label(cpu.core_type), cpu.id) .set_style(theme::VALUE), ), - Cell::from(freq.set_style(theme::VALUE)), + Cell::from(freq.set_style(freq_style)), Cell::from( pkg_power_w .map(|w| format!("{w:.1}"))