Skip to content

Commit

Permalink
Merge pull request #58 from haimgel/fix/better-display-id-on-linux
Browse files Browse the repository at this point in the history
Better display ID on Linux (#54)
  • Loading branch information
haimgel committed Jun 13, 2021
2 parents 5f5ee6e + 5a1567e commit 2943d3b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/display_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ const INPUT_SELECT: u8 = 0x60;
const RETRY_DELAY_MS: u64 = 3000;

fn display_name(display: &Display, index: Option<usize>) -> String {
// Different OSes populate different fields of ddc-hi-rs info structure differently. Create
// a synthetic "display_name" that makes sense on each OS
#[cfg(target_os = "linux")]
let display_id =
vec![&display.info.manufacturer_id, &display.info.model_name, &display.info.serial_number]
.into_iter()
.flatten()
.map(|s| s.as_str() )
.collect::<Vec<&str>>()
.join(" ");
#[cfg(target_os = "macos")]
let display_id = &display.info.id;
#[cfg(target_os = "windows")]
let display_id = &display.info.id;

if let Some(index) = index {
format!("'{} #{}'", display.info.id, index)
format!("'{} #{}'", display_id, index)
} else {
format!("'{}'", display.info.id)
format!("'{}'", display_id)
}
}

Expand Down

0 comments on commit 2943d3b

Please sign in to comment.