28 releases

new 0.5.2 Nov 10, 2024
0.5.1 Apr 27, 2024
0.5.0 Mar 5, 2024
0.4.4 Dec 22, 2023
0.3.2 Jul 31, 2022

#293 in Images

Download history 1136/week @ 2024-07-28 1183/week @ 2024-08-04 907/week @ 2024-08-11 660/week @ 2024-08-18 795/week @ 2024-08-25 776/week @ 2024-09-01 1055/week @ 2024-09-08 846/week @ 2024-09-15 1033/week @ 2024-09-22 1058/week @ 2024-09-29 995/week @ 2024-10-06 1064/week @ 2024-10-13 967/week @ 2024-10-20 1082/week @ 2024-10-27 1104/week @ 2024-11-03 1065/week @ 2024-11-10

4,373 downloads per month
Used in 18 crates (6 directly)

Custom license

26KB
565 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
  • 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.1–40MB
~629K SLoC