From 491f8b8fb16103183be40240e692eb8a992896d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Sat, 5 Oct 2024 22:16:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20compositors=20not=20supported=20by=20?= =?UTF-8?q?=C3=9Cberzug=20Wayland=20layer,=20or=20WSL=20not=20with=20WezTe?= =?UTF-8?q?rm=20should=20fallback=20to=20Chafa=20(#1735)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yazi-adapter/src/adapter.rs | 12 +++++------- yazi-plugin/preset/plugins/video.lua | 7 ++++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/yazi-adapter/src/adapter.rs b/yazi-adapter/src/adapter.rs index 6d84954d..841effe8 100644 --- a/yazi-adapter/src/adapter.rs +++ b/yazi-adapter/src/adapter.rs @@ -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(); @@ -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 diff --git a/yazi-plugin/preset/plugins/video.lua b/yazi-plugin/preset/plugins/video.lua index 3bcf15c4..4b30570b 100644 --- a/yazi-plugin/preset/plugins/video.lua +++ b/yazi-plugin/preset/plugins/video.lua @@ -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