From 003c29508474986bab191f536960f2e8b446882c Mon Sep 17 00:00:00 2001 From: a catgirl <75321465+a-catgirl-dev@users.noreply.github.com> Date: Sat, 23 Aug 2025 20:34:57 -0400 Subject: [PATCH] [F] fix: custom *fetch configurations breaking hyfetch (#420) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if the backend is fastfetch, hyfetch calls `/bin/fastfetch --logo none -s OS --disable-linewrap` which for me returns: `  Artix Linux x86_64` ... and that breaks hyfetch instead, get the information from the source (/etc/os-release), which im pretty sure most fetch backends read from anyway this won't work on *BSD though, because those lack /etc/os-release, so unless calling `uname -s` is alright, BSDs would still have the problem related pull: https://github.com/hykilpikonna/hyfetch/issues/418 --- crates/hyfetch/src/neofetch_util.rs | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/hyfetch/src/neofetch_util.rs b/crates/hyfetch/src/neofetch_util.rs index d6896e02..11782809 100644 --- a/crates/hyfetch/src/neofetch_util.rs +++ b/crates/hyfetch/src/neofetch_util.rs @@ -483,9 +483,34 @@ where #[tracing::instrument(level = "debug")] pub fn get_distro_name(backend: Backend) -> Result { + use std::collections::HashMap; + use std::fs; + + fn parse_os_release() -> Option> { + let contents = fs::read_to_string("/etc/os-release").ok()?; + let mut map = HashMap::new(); + + for line in contents.lines() { + if line.trim().is_empty() || line.starts_with('#') { + continue; + } + if let Some((key, value)) = line.split_once('=') { + let mut val = value.trim().to_string(); + if val.starts_with('"') && val.ends_with('"') && val.len() > 1 { + val = val[1..val.len().saturating_sub(1)].to_string(); + } + map.insert(key.to_string(), val); + } + } + + Some(map) + } + match backend { + #[cfg(not(target_os = "linux"))] Backend::Neofetch => run_neofetch_command_piped(&["ascii_distro_name"]) .context("failed to get distro name from neofetch"), + #[cfg(not(target_os = "linux"))] Backend::Fastfetch => Ok(run_fastfetch_command_piped(&[ "--logo", "none", @@ -493,6 +518,11 @@ pub fn get_distro_name(backend: Backend) -> Result { "OS", "--disable-linewrap", ]).context("failed to get distro name from fastfetch")?.replace("OS: ", "")), + #[cfg(target_os = "linux")] + Backend::Neofetch | Backend::Fastfetch => parse_os_release() + .context("failed to read /etc/os-release")? + .get("NAME").context("no NAME in /etc/os-release") + .cloned(), #[cfg(feature = "macchina")] Backend::Macchina => { // Write ascii art to temp file