From ab02f3c39e87eab7013453c6d9d1368c971c2c91 Mon Sep 17 00:00:00 2001 From: Adrian Groh Date: Fri, 24 Feb 2023 18:57:29 +0100 Subject: [PATCH] fix: fix os and host detection on Windows --- src/lib.rs | 11 +++++------ src/main.rs | 30 ++++++++++++++++-------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e5b9b02..e92a1a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -341,13 +341,12 @@ pub fn host(general_readout: &GeneralReadout) -> Option { Some(final_str) } } - "macos" => match general_readout.machine() { + _ => match general_readout.machine() { Ok(host) => Some(host), - Err(_) => None, - }, - _ => match general_readout.cpu_model_name() { - Ok(host) => Some(host), - Err(_) => None, + Err(_) => match general_readout.cpu_model_name() { + Ok(host) => Some(host), + Err(_) => None, + }, }, } } diff --git a/src/main.rs b/src/main.rs index f8a0e08..14c1d15 100644 --- a/src/main.rs +++ b/src/main.rs @@ -251,7 +251,7 @@ fn main() { kernel_readout: KernelReadout::new(), }; - let os = get_info(&PfetchInfo::Os, &readouts, skip_slow_package_managers).unwrap_or_default(); + let os = pfetch::os(&GeneralReadout::new()).unwrap_or_default(); let logo_override = env::var("PF_ASCII"); @@ -277,19 +277,21 @@ fn main() { let gathered_pfetch_info: Vec<(pfetch::Color, String, String)> = enabled_pf_info .iter() - .filter_map(|info| { - let info_result = get_info(info, &readouts, skip_slow_package_managers); - match info_result { - Some(info_str) => match info { - PfetchInfo::Title => Some((logo.secondary_color, info_str, "".to_string())), - PfetchInfo::Os => Some((logo.primary_color, info.to_string(), os.to_owned())), - PfetchInfo::BlankLine => { - Some((logo.primary_color, "".to_string(), "".to_string())) - } - PfetchInfo::Palette => Some((logo.primary_color, info_str, "".to_string())), - _ => Some((logo.primary_color, info.to_string(), info_str)), - }, - None => None, + .filter_map(|info| match info { + PfetchInfo::Os => Some((logo.primary_color, info.to_string(), os.clone())), + _ => { + let info_result = get_info(info, &readouts, skip_slow_package_managers); + match info_result { + Some(info_str) => match info { + PfetchInfo::Title => Some((logo.secondary_color, info_str, "".to_string())), + PfetchInfo::BlankLine => { + Some((logo.primary_color, "".to_string(), "".to_string())) + } + PfetchInfo::Palette => Some((logo.primary_color, info_str, "".to_string())), + _ => Some((logo.primary_color, info.to_string(), info_str)), + }, + None => None, + } } }) .collect();