General clean up

* Option changed: --debug-icons -> --debug-modules
This commit is contained in:
Mahesh Asolkar 2025-06-06 18:10:43 -07:00
parent 750a2813d3
commit 17ce090ef8
Signed by: asolkar
GPG Key ID: 371CA8164433BDCC
4 changed files with 12 additions and 31 deletions

View File

@ -121,9 +121,9 @@ impl bar_modules::BarModuleActions for UnibarModuleCpu {
// -------------------- // --------------------
fn generate_data(&mut self) { fn generate_data(&mut self) {
self.cpu_times_sample_1 = self.read_cpu_times().expect("REASON"); self.cpu_times_sample_1 = self.read_cpu_times().expect("Trouble getting CPU times sample 1");
thread::sleep(Duration::from_millis(1000)); thread::sleep(Duration::from_millis(500));
self.cpu_times_sample_2 = self.read_cpu_times().expect("REASON"); self.cpu_times_sample_2 = self.read_cpu_times().expect("Trouble getting CPU times sample 2");
if self.opts.debug { if self.opts.debug {
println!("-----> CPU times sample 1 - {:#?}", self.cpu_times_sample_1); println!("-----> CPU times sample 1 - {:#?}", self.cpu_times_sample_1);
@ -148,25 +148,6 @@ impl bar_modules::BarModuleActions for UnibarModuleCpu {
} else { } else {
return format!("CPU?"); return format!("CPU?");
} }
// let re = Regex::new(r"cpu\s+.*").unwrap();
// let caps = re.captures(self.procstat_str.as_str()).unwrap();
// let cpu_line = caps.get(0).unwrap().as_str();
// if self.opts.debug {
// println!("-----> CPU line - {:#?}", cpu_line);
// }
// let binding = Regex::new(r"\s+").unwrap();
// let mut parts :Vec<&str> = binding.split(cpu_line).collect();
// parts.remove(0); // Remove the 'cpu' part
// let cpu_idle :f32 = parts[3].parse::<f32>().unwrap();
// let mut cpu_total :f32 = 0.0;
// for usg in parts {
// cpu_total += usg.parse::<f32>().unwrap();
// }
// return format!("{}%", (((cpu_total - cpu_idle)/cpu_total) * 100.0).ceil() as i32);
} }
// -------------------- // --------------------

View File

@ -188,7 +188,7 @@ impl bar_modules::BarModuleActions for UnibarModuleWeather {
let temperature_unit :String = self.get_temperature_unit(); let temperature_unit :String = self.get_temperature_unit();
// let temperature_icon :String = self.get_icon(v.clone()); // let temperature_icon :String = self.get_icon(v.clone());
return format!("{:.2}{}", temperature_value, temperature_unit); return format!("{:.0}{}", temperature_value, temperature_unit);
} }
// -------------------- // --------------------
@ -198,7 +198,6 @@ impl bar_modules::BarModuleActions for UnibarModuleWeather {
let json_val = self.weather_info["features"][0]["properties"]["icon"].to_string(); let json_val = self.weather_info["features"][0]["properties"]["icon"].to_string();
let caps = re.captures(&json_val).unwrap(); let caps = re.captures(&json_val).unwrap();
// println!("{}", caps.get(1).unwrap().as_str());
return self.get_unicode_symbol(caps.get(1).unwrap().as_str()); return self.get_unicode_symbol(caps.get(1).unwrap().as_str());
} }
} }

View File

@ -27,5 +27,5 @@ pub struct AppOptions {
pub weather_station: String, pub weather_station: String,
pub music_progress: bool, pub music_progress: bool,
pub debug: bool, pub debug: bool,
pub debug_icons: bool, pub debug_modules: bool,
} }

View File

@ -26,13 +26,14 @@ struct CommandlineArgs {
#[arg(short = 'p', long)] #[arg(short = 'p', long)]
music_progress: bool, music_progress: bool,
/// Show JSON data returned by query /// Show verbose debug information during run
#[arg(short = 'D', long)] #[arg(short = 'D', long)]
debug: bool, debug: bool,
/// Show ICON debug information /// Show module debug information after all modules are evaluated
#[arg(short = 'I', long)] /// but before output is printed
debug_icons: bool, #[arg(short = 'M', long)]
debug_modules: bool,
} }
// //
@ -80,7 +81,7 @@ impl Unibar {
} }
// Show module debug information if enabled // Show module debug information if enabled
if self.opts.debug_icons { if self.opts.debug_modules {
let bar_modules_debugged: Vec<Box<dyn bar_modules::BarModuleDebug>> = vec! [ let bar_modules_debugged: Vec<Box<dyn bar_modules::BarModuleDebug>> = vec! [
Box::new(bar_modules::bar_module_weather::UnibarModuleWeather::new(self.opts.clone())), Box::new(bar_modules::bar_module_weather::UnibarModuleWeather::new(self.opts.clone())),
Box::new(bar_modules::bar_module_music::UnibarModuleMusic::new(self.opts.clone())), Box::new(bar_modules::bar_module_music::UnibarModuleMusic::new(self.opts.clone())),
@ -125,7 +126,7 @@ fn main() {
weather_station: cmd_args.weather_station, weather_station: cmd_args.weather_station,
music_progress: cmd_args.music_progress, music_progress: cmd_args.music_progress,
debug: cmd_args.debug, debug: cmd_args.debug,
debug_icons: cmd_args.debug_icons debug_modules: cmd_args.debug_modules
}, },
}; };