Crates.io | display-info |
lib.rs | display-info |
version | |
source | src |
created_at | 2022-04-13 04:48:52.815167+00 |
updated_at | 2025-02-02 04:51:27.948188+00 |
description | Cross-platform get display info |
homepage | https://github.com/nashaofu/display-info |
repository | https://github.com/nashaofu/display-info.git |
max_upload_size | |
id | 566799 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Cross-platform get display info for MacOS、Windows、Linux. Like electron Display Object
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());
}
id
u32 - Unique identifier associated with the display.name
String - The name of the displayfriendly_name
String - The display friendly name,raw_handle
CGDisplay/HMONITOR/Output - Native display raw handlex
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 screenOn Linux, you need to install libxcb
、libxrandr
Debian/Ubuntu:
apt-get install libxcb1 libxrandr2
Alpine:
apk add libxcb libxrandr
ArchLinux:
pacman -S libxcb libxrandr