fix: use WAYLAND_DISPLAY and DISPLAY to detect X11/Wayland when XDG_SESSION_TYPE is not set

This commit is contained in:
sxyazi 2023-10-24 10:06:36 +08:00
parent 8aeef55b6f
commit 4f282b61cb
No known key found for this signature in database

View file

@ -61,6 +61,11 @@ impl Adaptor {
"wayland" => return Self::Wayland,
_ => {}
}
if env::var_os("WAYLAND_DISPLAY").filter(|s| !s.is_empty()).is_some() {
return Self::Wayland;
}
if env::var_os("DISPLAY").filter(|s| !s.is_empty()).is_some() {
return Self::X11;
if std::fs::symlink_metadata("/proc/sys/fs/binfmt_misc/WSLInterop").is_ok() {
return Self::Kitty;
}