Skip to main content

detect

Function detect 

Source
pub fn detect(
    session_type: Option<&str>,
    wayland_display: Option<&str>,
    x_display: Option<&str>,
) -> Server
Expand description

Decide from the three variables that describe a Linux session.

XDG_SESSION_TYPE is the authority when it says something meaningful, because it is what the login session itself declares. The socket variables are the fallback, and WAYLAND_DISPLAY is checked first on purpose: a Wayland session almost always also sets DISPLAY, for XWayland. Trusting DISPLAY first would misread nearly every modern desktop as X11 — which is exactly the half-working failure above.