From bdee1a657699a77bc4cdb050f7355f37f64c45a6 Mon Sep 17 00:00:00 2001 From: ilyx <87244515+ilyx-me@users.noreply.github.com> Date: Mon, 8 Sep 2025 12:13:04 -0700 Subject: Don't clear DISPLAY/WAYLAND_DISPLAY/WAYLAND_SOCKET on WSL with --session (#2354) * use winit backend on WSL * Update src/main.rs --------- Co-authored-by: Ivan Molodetskikh --- src/main.rs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index caceebfc..118fe27a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,20 +70,23 @@ fn main() -> Result<(), Box> { let cli = Cli::parse(); if cli.session { - // If we're starting as a session, assume that the intention is to start on a TTY. Remove - // DISPLAY, WAYLAND_DISPLAY or WAYLAND_SOCKET from our environment if they are set, since - // they will cause the winit backend to be selected instead. - if env::var_os("DISPLAY").is_some() { - warn!("running as a session but DISPLAY is set, removing it"); - env::remove_var("DISPLAY"); - } - if env::var_os("WAYLAND_DISPLAY").is_some() { - warn!("running as a session but WAYLAND_DISPLAY is set, removing it"); - env::remove_var("WAYLAND_DISPLAY"); - } - if env::var_os("WAYLAND_SOCKET").is_some() { - warn!("running as a session but WAYLAND_SOCKET is set, removing it"); - env::remove_var("WAYLAND_SOCKET"); + // If we're starting as a session, assume that the intention is to start on a TTY unless + // this is a WSL environment. Remove DISPLAY, WAYLAND_DISPLAY or WAYLAND_SOCKET from our + // environment if they are set, since they will cause the winit backend to be selected + // instead. + if env::var_os("WSL_DISTRO_NAME").is_none() { + if env::var_os("DISPLAY").is_some() { + warn!("running as a session but DISPLAY is set, removing it"); + env::remove_var("DISPLAY"); + } + if env::var_os("WAYLAND_DISPLAY").is_some() { + warn!("running as a session but WAYLAND_DISPLAY is set, removing it"); + env::remove_var("WAYLAND_DISPLAY"); + } + if env::var_os("WAYLAND_SOCKET").is_some() { + warn!("running as a session but WAYLAND_SOCKET is set, removing it"); + env::remove_var("WAYLAND_SOCKET"); + } } // Set the current desktop for xdg-desktop-portal. -- cgit