perf: prefer libmacchina readouts over dotenvy

This commit is contained in:
Adrian Groh 2023-03-09 14:21:39 +01:00
parent f3592774b5
commit 8c53f0111f
Signed by: Gobidev
GPG Key ID: 3AA3153E98B0D771
3 changed files with 11 additions and 23 deletions

View File

@ -146,15 +146,6 @@ USER=""
# Which hostname to display. # Which hostname to display.
HOSTNAME="" HOSTNAME=""
# Which editor to display.
EDITOR=""
# Which shell to display.
SHELL=""
# Which desktop environment to display.
XDG_CURRENT_DESKTOP=""
# Skip package managers that take "long" to query package count (like nix) # Skip package managers that take "long" to query package count (like nix)
PF_FAST_PKG_COUNT=1 PF_FAST_PKG_COUNT=1
``` ```

View File

@ -356,7 +356,10 @@ pub fn shell(general_readout: &GeneralReadout) -> Option<String> {
libmacchina::traits::ShellKind::Default, libmacchina::traits::ShellKind::Default,
) { ) {
Ok(shell) => Some(shell), Ok(shell) => Some(shell),
Err(_) => None, Err(_) => match dotenvy::var("SHELL") {
Ok(shell) => Some(shell),
Err(_) => None,
},
} }
} }
@ -380,7 +383,10 @@ pub fn wm(general_readout: &GeneralReadout) -> Option<String> {
pub fn de(general_readout: &GeneralReadout) -> Option<String> { pub fn de(general_readout: &GeneralReadout) -> Option<String> {
match general_readout.desktop_environment() { match general_readout.desktop_environment() {
Ok(de) => Some(de), Ok(de) => Some(de),
Err(_) => None, Err(_) => match dotenvy::var("XDG_CURRENT_DESKTOP") {
Ok(de) => Some(de),
Err(_) => None,
},
} }
} }

View File

@ -183,19 +183,10 @@ fn get_info(
.to_string(), .to_string(),
), ),
PfetchInfo::Memory => pfetch::memory(&readouts.memory_readout), PfetchInfo::Memory => pfetch::memory(&readouts.memory_readout),
PfetchInfo::Shell => match dotenvy::var("SHELL") { PfetchInfo::Shell => pfetch::shell(&readouts.general_readout),
Ok(shell) => Some(shell), PfetchInfo::Editor => pfetch::editor(),
Err(_) => pfetch::shell(&readouts.general_readout),
},
PfetchInfo::Editor => match dotenvy::var("EDITOR") {
Ok(editor) => Some(editor),
Err(_) => pfetch::editor(),
},
PfetchInfo::Wm => pfetch::wm(&readouts.general_readout), PfetchInfo::Wm => pfetch::wm(&readouts.general_readout),
PfetchInfo::De => match dotenvy::var("XDG_CURRENT_DESKTOP") { PfetchInfo::De => pfetch::de(&readouts.general_readout),
Ok(de) => Some(de),
Err(_) => pfetch::de(&readouts.general_readout),
},
PfetchInfo::Palette => Some(pfetch::palette()), PfetchInfo::Palette => Some(pfetch::palette()),
PfetchInfo::BlankLine => Some("".to_string()), PfetchInfo::BlankLine => Some("".to_string()),
} }