all GPUs should print on their own lines now

This commit is contained in:
river 2023-03-28 23:04:21 -04:00
parent 875cf9942a
commit cdd145ff41
4 changed files with 26 additions and 12 deletions

2
Cargo.lock generated
View File

@ -333,7 +333,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
[[package]]
name = "oxidefetch"
version = "1.2.1"
version = "1.2.2"
dependencies = [
"byte-unit",
"chrono",

View File

@ -1,6 +1,6 @@
[package]
name = "oxidefetch"
version = "1.2.1"
version = "1.2.2"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,4 +1,4 @@
# oxidefetch 1.2.1
# oxidefetch 1.2.2
Fully cross platform Neofetch clone written in Rust. Up to 25 times faster than Neofetch!
![alt text](image.png "Example output of OxideFetch on a WSL2 Arch Linux host")
@ -75,3 +75,4 @@ No weird quirks to report at this time.
**1.1.2:** Replaced *nix dependency on ```bash``` with dependency on ```sh```.
**1.2.0:** Allowed users to enable field titles as a compile-time feature. Tentative fix for GPU display issues on Linux.
**1.2.1:** Stable fix for GPU display quirks.
**1.2.2:** All GPUs should print in their own lines.

View File

@ -38,7 +38,12 @@ fn main() {
color_print("Uptime:\t", '', &Some(sys_info.uptime), "bright black");
color_print("Shell:\t", '', &sys_info.shell, "bright magenta");
color_print("CPU:\t", '', &Some(sys_info.cpu), "green");
color_print("GPU:\t", '', &sys_info.gpu, "bright green");
if let Some(gpus) = sys_info.gpu {
for gpu in gpus {
color_print("GPU:\t", '', &Some(gpu), "bright green")
}
}
//color_print("GPU:\t", '', &sys_info.gpu, "bright green");
color_print("Memory:\t", '', &Some(sys_info.memory), "bright blue");
}
@ -69,7 +74,7 @@ struct InformationStruct {
shell: Option<String>,
terminal: Option<String>,
cpu: String,
gpu: Option<String>,
gpu: Option<Vec<String>>,
memory: String,
icon: char,
color: String,
@ -121,13 +126,13 @@ impl InformationStruct {
match command_output {
Ok(gpu_info) => {
let gpu_info_as_string = String::from_utf8(gpu_info.stdout);
Some(String::from(
Some(vec![String::from(
gpu_info_as_string
.unwrap() // TODO: Please figure out a way to get rid of this unwrap() call.
// I feel like I did so well avoiding unwrap calls everywhere except for here.
.split("\n")
.collect::<Vec<&str>>()[1],
))
)])
}
Err(_) => None,
}
@ -140,16 +145,24 @@ impl InformationStruct {
.output();
let gpu = match command_output {
Ok(gpu_info) => Some(
String::from_utf8(gpu_info.stdout)
vec![
String::from_utf8(gpu_info.stdout)
.unwrap()
.trim()
.replace("\n", ", ")
.to_owned(),
.split("\n")
.to_owned()
.collect(),
]
),
Err(_) => None,
};
if gpu == Some(String::from("")) {
None
// If the GPU vec is empty we just return None
if let Some(gpu_check) = &gpu {
if gpu_check.len() == 0 {
None
} else {
gpu
}
} else {
gpu
}