fix: check compositor support status before using ueberzug wayland output

This commit is contained in:
taoky 2024-08-29 01:24:32 +08:00
parent ddb8ce530f
commit 220354727e

View file

@ -95,12 +95,20 @@ impl Adapter {
return *p;
}
// Currently Überzug++'s Wayland output only supports Sway, Hyprland and Wayfire
// as it requires information from specific compositior socket directly.
// These environment variables are from ueberzugpp src/canvas/wayland/config.cpp
let supports_ueberzug_wayland = env_exists("SWAYSOCK")
|| env_exists("HYPRLAND_INSTANCE_SIGNATURE")
|| env_exists("WAYFIRE_SOCKET");
match env::var("XDG_SESSION_TYPE").unwrap_or_default().as_str() {
"x11" => return Self::X11,
"wayland" => return Self::Wayland,
"wayland" if supports_ueberzug_wayland => return Self::Wayland,
"wayland" if !supports_ueberzug_wayland => warn!("[Adapter] Unsupported Wayland compositor"),
_ => warn!("[Adapter] Could not identify XDG_SESSION_TYPE"),
}
if env_exists("WAYLAND_DISPLAY") {
if supports_ueberzug_wayland && env_exists("WAYLAND_DISPLAY") {
return Self::Wayland;
}
if env_exists("DISPLAY") {