display_info/linux/
mod.rs1use std::env::var_os;
2
3pub use xorg::ScreenRawHandle;
4
5use crate::{DisplayInfo, error::DIResult};
6
7mod wayland;
8mod xorg;
9
10fn is_wayland() -> bool {
11 var_os("WAYLAND_DISPLAY")
12 .or(var_os("XDG_SESSION_TYPE"))
13 .is_some_and(|v| {
14 v.to_str()
15 .unwrap_or_default()
16 .to_lowercase()
17 .contains("wayland")
18 })
19}
20
21impl DisplayInfo {
22 pub fn all() -> DIResult<Vec<DisplayInfo>> {
23 if is_wayland() {
24 wayland::get_all()
25 } else {
26 xorg::get_all()
27 }
28 }
29
30 pub fn from_point(x: i32, y: i32) -> DIResult<DisplayInfo> {
31 if is_wayland() {
32 wayland::get_from_point(x, y)
33 } else {
34 xorg::get_from_point(x, y)
35 }
36 }
37}