Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compositors not supported by Überzug Wayland layer, or WSL not with WezTerm should fallback to Chafa #1735

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions yazi-adapter/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ impl Adapter {
impl Adapter {
pub fn matches() -> Self {
let emulator = Emulator::detect();
#[cfg(windows)]
if matches!(emulator, Emulator::Microsoft) {
return Self::Sixel;
} else if *WSL && matches!(emulator, Emulator::WezTerm) {
return Self::KgpOld;
}

let mut protocols = emulator.adapters();
Expand All @@ -104,18 +105,15 @@ impl Adapter {
match env::var("XDG_SESSION_TYPE").unwrap_or_default().as_str() {
"x11" => return Self::X11,
"wayland" if supported_compositor => return Self::Wayland,
"wayland" if !supported_compositor => warn!("[Adapter] Unsupported Wayland compositor"),
"wayland" if !supported_compositor => return Self::Chafa,
_ => warn!("[Adapter] Could not identify XDG_SESSION_TYPE"),
}
if supported_compositor && env_exists("WAYLAND_DISPLAY") {
return Self::Wayland;
if env_exists("WAYLAND_DISPLAY") {
return if supported_compositor { Self::Wayland } else { Self::Chafa };
}
if env_exists("DISPLAY") {
return Self::X11;
}
if *WSL {
return Self::KgpOld;
}

warn!("[Adapter] Falling back to chafa");
Self::Chafa
Expand Down
7 changes: 6 additions & 1 deletion yazi-plugin/preset/plugins/video.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function M:preload()
end

local cache = ya.file_cache(self)
if not cache or fs.cha(cache) then
if not cache then
return 1
end

local cha = fs.cha(cache)
if cha and cha.length > 0 then
return 1
end

Expand Down