focus-tracker 1.1.0

Cross-platform focus tracker for Linux (X11), macOS and Windows
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::env::var_os;

/// Checks if Wayland based on two common variables:
/// - `XDG_SESSION_TYPE` — set by the display manager, compared case-insensitively
/// - `WAYLAND_DISPLAY` — set by the compositor when a Wayland socket is available;
pub fn wayland_detect() -> bool {
    let is_wayland_session = var_os("XDG_SESSION_TYPE")
        .map(|v| v.to_string_lossy().eq_ignore_ascii_case("wayland"))
        .unwrap_or(false);

    let has_wayland_display = var_os("WAYLAND_DISPLAY")
        .map(|v| !v.is_empty())
        .unwrap_or(false);

    is_wayland_session || has_wayland_display
}