#screen #info #display

display-info

Cross-platform get display info

30 releases

0.5.4 Feb 2, 2025
0.5.2 Nov 10, 2024
0.5.1 Apr 27, 2024
0.5.0 Mar 5, 2024
0.3.2 Jul 31, 2022

#4 in #screen

Download history 1755/week @ 2025-02-04 1588/week @ 2025-02-11 1707/week @ 2025-02-18 3142/week @ 2025-02-25 1508/week @ 2025-03-04 2137/week @ 2025-03-11 1621/week @ 2025-03-18 1461/week @ 2025-03-25 1094/week @ 2025-04-01 1339/week @ 2025-04-08 1257/week @ 2025-04-15 1599/week @ 2025-04-22 1532/week @ 2025-04-29 1501/week @ 2025-05-06 1256/week @ 2025-05-13 1566/week @ 2025-05-20

6,102 downloads per month
Used in 18 crates (7 directly)

Custom license

38KB
815 lines

display-info

Cross-platform get display info for MacOS、Windows、Linux. Like electron Display Object

Example

use display_info::DisplayInfo;
use std::time::Instant;

fn main() {
  let start = Instant::now();

  let display_infos = DisplayInfo::all().unwrap();
  for display_info in display_infos {
    println!("display_info {display_info:?}");
  }
  let display_info = DisplayInfo::from_point(100, 100).unwrap();
  println!("display_info {display_info:?}");
  println!("运行耗时: {:?}", start.elapsed());
}

DisplayInfo struct

  • id u32 - Unique identifier associated with the display.
  • name String - The name of the display
  • friendly_name String - The display friendly name,
  • raw_handle CGDisplay/HMONITOR/Output - Native display raw handle
  • x i32 - The display x coordinate.
  • y i32 - The display y coordinate.
  • width u32 - The display pixel width.
  • height u32 - The display pixel height.
  • width_mm i32 - The width of a display in millimeters. This value may be 0.
  • height_mm i32 - The height of a display in millimeters. This value may be 0.
  • rotation f32 - Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.
  • scale_factor f32 - Output device's pixel scale factor.
  • frequency f32 - The display refresh rate.
  • is_primary bool - Whether the screen is the main screen

Linux requirements

On Linux, you need to install libxcblibxrandr

Debian/Ubuntu:

apt-get install libxcb1 libxrandr2

Alpine:

apk add libxcb libxrandr

ArchLinux:

pacman -S libxcb libxrandr

Dependencies

~0.3–41MB
~636K SLoC