Skip to content

Commit

Permalink
fix: use WAYLAND_DISPLAY and DISPLAY to detect X11/Wayland when `…
Browse files Browse the repository at this point in the history
…XDG_SESSION_TYPE` is not set
  • Loading branch information
sxyazi committed Oct 24, 2023
1 parent 6a651f4 commit 10456c5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions yazi-adaptor/src/adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ impl Adaptor {
_ => {}
}
match env::var("XDG_SESSION_TYPE").unwrap_or_default().as_str() {
"x11" => Self::X11,
"wayland" => Self::Wayland,
_ => Self::Chafa,
"x11" => return Self::X11,
"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;
}
Self::Chafa
}

pub(super) fn term_program() -> (String, String) {
Expand Down

0 comments on commit 10456c5

Please sign in to comment.