You've already forked neo64fetch
mirror of
https://github.com/neoarz/neo64fetch.git
synced 2026-02-19 19:53:26 +01:00
fix: formatting for display and battery
This commit is contained in:
@@ -2,6 +2,7 @@ use display_info::DisplayInfo;
|
||||
|
||||
pub fn get_display_info() -> String {
|
||||
let displays = DisplayInfo::all().unwrap_or_else(|_| vec![]);
|
||||
let display_count = displays.len();
|
||||
|
||||
if let Some(main) = displays.iter().find(|d| d.is_primary) {
|
||||
let p_width = (main.width as f32 * main.scale_factor) as u32;
|
||||
@@ -10,22 +11,24 @@ pub fn get_display_info() -> String {
|
||||
let diag_mm = ((main.width_mm as f32).powi(2) + (main.height_mm as f32).powi(2)).sqrt();
|
||||
let inches = (diag_mm / 25.4).round() as u32;
|
||||
|
||||
let name = if main.name.is_empty() {
|
||||
"Color LCD"
|
||||
} else {
|
||||
&main.name
|
||||
};
|
||||
|
||||
let tag = if main.is_primary {
|
||||
"[Built-in]"
|
||||
} else {
|
||||
"[External]"
|
||||
};
|
||||
|
||||
format!(
|
||||
"({}): {}x{} @ {}x in {}\", {} Hz {}",
|
||||
name, p_width, p_height, main.scale_factor as u32, inches, main.frequency as u32, tag
|
||||
)
|
||||
if display_count > 1 {
|
||||
let name = if main.name.is_empty() { "Color LCD" } else { &main.name };
|
||||
format!(
|
||||
"({}) {}x{} @ {}x in {}\", {} Hz {}",
|
||||
name, p_width, p_height, main.scale_factor as u32, inches, main.frequency as u32, tag
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"{}x{} @ {}x in {}\", {} Hz {}",
|
||||
p_width, p_height, main.scale_factor as u32, inches, main.frequency as u32, tag
|
||||
)
|
||||
}
|
||||
} else {
|
||||
"unknown".to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user