Don't clear DISPLAY/WAYLAND_DISPLAY/WAYLAND_SOCKET on WSL with --session (#2354)
Browse files at this commit1 changed file +17 -14
- src/main.rs +17 -14
src/main.rsmodified+17 -14
| @@ -70,20 +70,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
| 70 | let cli = Cli::parse(); | 70 | let cli = Cli::parse(); |
| 71 | 71 | ||
| 72 | if cli.session { | 72 | if cli.session { |
| 73 | - // If we're starting as a session, assume that the intention is to start on a TTY. Remove | 73 | + // If we're starting as a session, assume that the intention is to start on a TTY unless |
| 74 | - // DISPLAY, WAYLAND_DISPLAY or WAYLAND_SOCKET from our environment if they are set, since | 74 | + // this is a WSL environment. Remove DISPLAY, WAYLAND_DISPLAY or WAYLAND_SOCKET from our |
| 75 | - // they will cause the winit backend to be selected instead. | 75 | + // environment if they are set, since they will cause the winit backend to be selected |
| 76 | - if env::var_os("DISPLAY").is_some() { | 76 | + // instead. |
| 77 | - warn!("running as a session but DISPLAY is set, removing it"); | 77 | + if env::var_os("WSL_DISTRO_NAME").is_none() { |
| 78 | - env::remove_var("DISPLAY"); | 78 | + if env::var_os("DISPLAY").is_some() { |
| 79 | - } | 79 | + warn!("running as a session but DISPLAY is set, removing it"); |
| 80 | - if env::var_os("WAYLAND_DISPLAY").is_some() { | 80 | + env::remove_var("DISPLAY"); |
| 81 | - warn!("running as a session but WAYLAND_DISPLAY is set, removing it"); | 81 | + } |
| 82 | - env::remove_var("WAYLAND_DISPLAY"); | 82 | + if env::var_os("WAYLAND_DISPLAY").is_some() { |
| 83 | - } | 83 | + warn!("running as a session but WAYLAND_DISPLAY is set, removing it"); |
| 84 | - if env::var_os("WAYLAND_SOCKET").is_some() { | 84 | + env::remove_var("WAYLAND_DISPLAY"); |
| 85 | - warn!("running as a session but WAYLAND_SOCKET is set, removing it"); | 85 | + } |
| 86 | - env::remove_var("WAYLAND_SOCKET"); | 86 | + if env::var_os("WAYLAND_SOCKET").is_some() { |
| 87 | + warn!("running as a session but WAYLAND_SOCKET is set, removing it"); | ||
| 88 | + env::remove_var("WAYLAND_SOCKET"); | ||
| 89 | + } | ||
| 87 | } | 90 | } |
| 88 | 91 | ||
| 89 | // Set the current desktop for xdg-desktop-portal. | 92 | // Set the current desktop for xdg-desktop-portal. |