You've already forked neo64fetch
mirror of
https://github.com/neoarz/neo64fetch.git
synced 2026-02-09 06:43:26 +01:00
36 lines
1.2 KiB
Rust
36 lines
1.2 KiB
Rust
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;
|
|
let p_height = (main.height as f32 * main.scale_factor) as u32;
|
|
|
|
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 tag = if main.is_primary {
|
|
"[Built-in]"
|
|
} else {
|
|
"[External]"
|
|
};
|
|
|
|
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()
|
|
}
|
|
}
|