33 releases

Uses new Rust 2024

0.5.7 Oct 16, 2025
0.5.5 Aug 17, 2025
0.5.4 Feb 2, 2025
0.5.2 Nov 10, 2024
0.3.2 Jul 31, 2022

#213 in Images

Download history 3388/week @ 2025-09-23 2968/week @ 2025-09-30 3772/week @ 2025-10-07 4672/week @ 2025-10-14 3740/week @ 2025-10-21 4395/week @ 2025-10-28 3407/week @ 2025-11-04 3137/week @ 2025-11-11 3912/week @ 2025-11-18 3981/week @ 2025-11-25 4586/week @ 2025-12-02 4934/week @ 2025-12-09 7597/week @ 2025-12-16 4945/week @ 2025-12-23 3624/week @ 2025-12-30 4415/week @ 2026-01-06

21,301 downloads per month
Used in 29 crates (16 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.2–38MB
~648K SLoC