use crate::cli::DisplayServerArg; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum DisplayServer { Wayland, X11, Unknown, } impl DisplayServer { pub fn detect() -> Self { if std::env::var_os("WAYLAND_DISPLAY").is_some() { return DisplayServer::Wayland; } if std::env::var_os("DISPLAY").is_some() { return DisplayServer::X11; } match std::env::var("XDG_SESSION_TYPE").as_deref() { Ok("wayland") => DisplayServer::Wayland, Ok("x11") => DisplayServer::X11, _ => DisplayServer::Unknown, } } pub fn resolve(override_: Option) -> Self { match override_ { Some(DisplayServerArg::Wayland) => DisplayServer::Wayland, Some(DisplayServerArg::X11) => DisplayServer::X11, None => DisplayServer::detect(), } } }