From 91b58cfaccecb1af9f6593f8eec645af65a7e4b9 Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 7 Jul 2026 02:19:49 +0300 Subject: [PATCH] redbear-power: show refresh interval in keybar (e.g. [/]:500ms) Track current poll_ms in App, update it on all three poll-change paths ([ / ] /Enter), and display it persistently in the keybar between governor and tab hints. --- local/recipes/system/redbear-power/source/src/app.rs | 2 ++ local/recipes/system/redbear-power/source/src/main.rs | 4 ++++ local/recipes/system/redbear-power/source/src/render.rs | 2 ++ 3 files changed, 8 insertions(+) diff --git a/local/recipes/system/redbear-power/source/src/app.rs b/local/recipes/system/redbear-power/source/src/app.rs index 58d1d0b4ff..70430bbd82 100644 --- a/local/recipes/system/redbear-power/source/src/app.rs +++ b/local/recipes/system/redbear-power/source/src/app.rs @@ -146,6 +146,7 @@ pub struct App { /// file read. Fields degrade to `None` when unavailable. pub sched_stats: crate::sched::SchedStats, pub load_avg: Option<(f64, f64, f64)>, + pub poll_ms: u64, /// When true, render the Process tab as a tree (parents above /// children, prefixed with `├─ ` / `└─ ` connector characters). /// Toggled by the `T` hotkey. Sort modes are honored within @@ -456,6 +457,7 @@ impl App { None } }), + poll_ms: crate::app::POLL_MS, process_tree: false, show_full_cmdline: false, folded: std::collections::BTreeSet::new(), diff --git a/local/recipes/system/redbear-power/source/src/main.rs b/local/recipes/system/redbear-power/source/src/main.rs index 55ac71eb80..6909b59230 100644 --- a/local/recipes/system/redbear-power/source/src/main.rs +++ b/local/recipes/system/redbear-power/source/src/main.rs @@ -319,6 +319,7 @@ fn main() -> io::Result<()> { } else { POLL_MS }); + app.poll_ms = poll.as_millis() as u64; let mut show_help = false; // Tab/BackTab cycles keyboard focus between header / table / controls. let mut focused_panel: usize = 1; @@ -1029,6 +1030,7 @@ fn main() -> io::Result<()> { if poll_idx > 0 { poll_idx -= 1; poll = Duration::from_millis(POLL_STEPS_MS[poll_idx]); + app.poll_ms = poll.as_millis() as u64; app.flash_status(format!("refresh → {} ms", poll.as_millis())); } else { app.flash_status("refresh already at minimum (250 ms)"); @@ -1038,6 +1040,7 @@ fn main() -> io::Result<()> { if poll_idx + 1 < POLL_STEPS_MS.len() { poll_idx += 1; poll = Duration::from_millis(POLL_STEPS_MS[poll_idx]); + app.poll_ms = poll.as_millis() as u64; app.flash_status(format!("refresh → {} ms", poll.as_millis())); } else { app.flash_status("refresh already at maximum (2000 ms)"); @@ -1064,6 +1067,7 @@ fn main() -> io::Result<()> { if let Ok(ms) = raw.parse::() { if (50..=60_000).contains(&ms) { poll = Duration::from_millis(ms); + app.poll_ms = ms; poll_idx = POLL_STEPS_MS .iter() .position(|&v| v == ms) diff --git a/local/recipes/system/redbear-power/source/src/render.rs b/local/recipes/system/redbear-power/source/src/render.rs index 659066cc07..805c650b6c 100644 --- a/local/recipes/system/redbear-power/source/src/render.rs +++ b/local/recipes/system/redbear-power/source/src/render.rs @@ -2042,6 +2042,7 @@ pub fn render_cpu_table<'a>( pub fn render_keybar<'a>(app: &'a App) -> Paragraph<'a> { let gov = format!(" g:{}", app.cpufreq.active.as_str()); + let interval = format!(" [/]:{}ms", app.poll_ms); let tab_hints: &str = if app.current_tab == crate::app::TabId::Process { " ↑↓:sel k:kill N:nice l:files C:cmd o:sort i:invert F:filter y:tree Enter:detail" } else { @@ -2049,6 +2050,7 @@ pub fn render_keybar<'a>(app: &'a App) -> Paragraph<'a> { }; let mut parts = vec![ gov, + interval, tab_hints.to_string(), " T:tab ?:help e:expand f:freeze q:quit".to_string(), ];