Shutdown logic & Panel

This commit is contained in:
Alex Emmet 2025-11-25 18:37:13 +00:00
commit 0ec6159365
7 changed files with 46 additions and 2 deletions

View file

@ -1,4 +1,5 @@
use crate::APP_STATE;
use crate::SHUTDOWN;
use crate::gui::ratatui_interface::TERMINAL;
use crate::gui::widgets::betterblock::draw_block_joins;
use crate::langu::language_manager::format;
@ -80,12 +81,15 @@ fn downsample_to_fit_width(data: &[(f64, f64)], width: u16) -> Vec<(f64, f64)> {
pub fn setup() {
// Start a background thread to sample metrics
thread::spawn(move || {
thread::spawn(async move || {
let mut sys = System::new_with_specifics(RefreshKind::new());
let mut last_total_received = 0u64;
let mut last_total_transmitted = 0u64;
let mut counter = 0.0;
loop {
if *SHUTDOWN.read().await {
break;
}
sys.refresh_all();
let mut tcpu = 0;

View file

@ -4,7 +4,7 @@ use std::{
time::Duration,
};
use crate::gui::nav_bar::NavBar;
use crate::{SHUTDOWN, gui::nav_bar::NavBar};
use color_eyre::Result;
use crossterm::{
execute,
@ -39,6 +39,9 @@ fn init_terminal() {
async fn run() -> Result<()> {
init_terminal();
loop {
if *SHUTDOWN.read().await {
return Ok(());
}
NAV_BAR.lock().await.current_screen.renderf();
tokio::time::sleep(Duration::from_millis(1000)).await;
}