GPU info blank fix for Linux. Might be broken.
This commit is contained in:
parent
cdd145ff41
commit
d4e00fc55f
55
src/main.rs
55
src/main.rs
@ -25,7 +25,7 @@ fn main() {
|
|||||||
// This should be done via some sort of user accessible, persistent config,
|
// This should be done via some sort of user accessible, persistent config,
|
||||||
// and preferably can be modified via env vars.
|
// and preferably can be modified via env vars.
|
||||||
println!("{}", String::from(">>> OxideFetch <<<").red());
|
println!("{}", String::from(">>> OxideFetch <<<").red());
|
||||||
color_print("Date:\t", '', &Some(datetime_formatted), "bright yellow");
|
color_print("Date:\t", '', &Some(datetime_formatted), "bright yellow");
|
||||||
color_print(
|
color_print(
|
||||||
"Host:\t",
|
"Host:\t",
|
||||||
'',
|
'',
|
||||||
@ -40,11 +40,11 @@ fn main() {
|
|||||||
color_print("CPU:\t", '', &Some(sys_info.cpu), "green");
|
color_print("CPU:\t", '', &Some(sys_info.cpu), "green");
|
||||||
if let Some(gpus) = sys_info.gpu {
|
if let Some(gpus) = sys_info.gpu {
|
||||||
for gpu in gpus {
|
for gpu in gpus {
|
||||||
color_print("GPU:\t", '', &Some(gpu), "bright green")
|
color_print("GPU:\t", '', &Some(gpu), "bright green")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//color_print("GPU:\t", '', &sys_info.gpu, "bright green");
|
//color_print("GPU:\t", '', &sys_info.gpu, "bright green");
|
||||||
color_print("Memory:\t", '', &Some(sys_info.memory), "bright blue");
|
color_print("Memory:\t", '', &Some(sys_info.memory), "bright blue");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn color_print(field_title: &str, icon: char, field: &Option<String>, color: &str) {
|
fn color_print(field_title: &str, icon: char, field: &Option<String>, color: &str) {
|
||||||
@ -143,29 +143,38 @@ impl InformationStruct {
|
|||||||
let command_output = std::process::Command::new("sh")
|
let command_output = std::process::Command::new("sh")
|
||||||
.args(["-c", "lspci | grep VGA | awk -F 'VGA compatible controller: ' '{print $2}'"])
|
.args(["-c", "lspci | grep VGA | awk -F 'VGA compatible controller: ' '{print $2}'"])
|
||||||
.output();
|
.output();
|
||||||
let gpu = match command_output {
|
|
||||||
Ok(gpu_info) => Some(
|
// Check if running the command resulted in an error
|
||||||
vec![
|
match command_output {
|
||||||
String::from_utf8(gpu_info.stdout)
|
|
||||||
.unwrap()
|
|
||||||
.trim()
|
|
||||||
.split("\n")
|
|
||||||
.to_owned()
|
|
||||||
.collect(),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
};
|
Ok(output_bytes) => {
|
||||||
// If the GPU vec is empty we just return None
|
match String::from_utf8(output_bytes.stdout) {
|
||||||
if let Some(gpu_check) = &gpu {
|
Err(_) => None,
|
||||||
if gpu_check.len() == 0 {
|
Ok(output_string) => {
|
||||||
None
|
match output_string.as_ref() {
|
||||||
} else {
|
"" => None,
|
||||||
gpu
|
_ => {
|
||||||
|
Some(vec![
|
||||||
|
output_string
|
||||||
|
.split("\n")
|
||||||
|
.collect()
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
gpu
|
|
||||||
}
|
}
|
||||||
|
// Convert the output bytes to a String
|
||||||
|
|
||||||
|
// Trim the string and check if it's empty or whitespace
|
||||||
|
|
||||||
|
// Return None if the string is empty or whitespace
|
||||||
|
|
||||||
|
// Split the string into lines and return it
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user