27 releases

0.5.1 Apr 27, 2024
0.5.0 Mar 5, 2024
0.4.9 Mar 3, 2024
0.4.4 Dec 22, 2023
0.3.2 Jul 31, 2022

#269 in Images

Download history 1052/week @ 2024-01-26 788/week @ 2024-02-02 1207/week @ 2024-02-09 814/week @ 2024-02-16 1012/week @ 2024-02-23 1088/week @ 2024-03-01 936/week @ 2024-03-08 738/week @ 2024-03-15 706/week @ 2024-03-22 755/week @ 2024-03-29 723/week @ 2024-04-05 809/week @ 2024-04-12 948/week @ 2024-04-19 915/week @ 2024-04-26 747/week @ 2024-05-03 443/week @ 2024-05-10

3,197 downloads per month
Used in 14 crates (2 directly)

Custom license

26KB
587 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.
  • 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

Minimum supported Windows 2000 Professional/Server

Using features gdi.

Dependencies

~0.1–43MB
~656K SLoC