简体   繁体   中英

How do I run VSCode in WSL in X server environment?

I have WSL 2 installed with Ubuntu and the i3 window manager. I want to run VSCode in the i3 x server environment, but whenever I run VSCode it's opened as a Microsoft Windows window. How do I force VSCode to be executed in the i3 x environment?

The main reason I use i3 is for tiling and lovely shortcuts, and the fact that VSCode is executed outside of this tiling environment makes it absolutely useless.


System information

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:    20.04
Codename:   focal

I3 wm version

i3 version 4.17.1 (2019-08-30) © 2009 Michael Stapelberg and contributors

vscode version

1.71.2
74b1f979648cc44d385a2286793c226e611f59e7
x64

Short answer: Install and use the Linux version of VSCode under WSL to have it be managed by i3.


Explanation:

i3 does not have the ability to understand or manage Windows applications running under the Windows Desktop Window Manager (DWM), as i3 is actually running inside a Windows application itself -- Your X display/server, whether that's WSLg, VcXsrv, etc.

There's probably no technical reason that I can think of that i3 (or another WM) couldn't be coded to manage both X applications and Windows applications under WSL. But as a Linux application, it shouldn't be surprising that i3 is only coded to manage X/Linux applications.

The main reason I use i3 is for tiling and lovely shortcuts, and the fact that VSCode is executed outside of this tiling environment makes it absolutely useless.

Are you just making that assertion about VSCode? Or is any Windows application that can't be managed by i3 "absolutely useless"? I ask because it seems you may be happier running either a pure-Linux environment or, if you are stuck on Windows for some reason, perhaps a full Linux virtual machine under Windows.

Either way--under WSL2, a VM, or pure Linux--you do have the option of installing and running the Linux version of VSCode, which should be manageable by i3.


I'm partial to the keyboard myself, so it's probably a good thing I never became hooked on i3, or I'd likely have a tough time making the transition to Windows.

While it's not in the same league as i3, if you do need to continue on Windows, you may want to install Microsoft's PowerToys, available in the Store. It includes:

  • PowerToys Run: A search/launcher in the spirit of Spotlight (and others). It could serve to replace (and probably exceed the functionality of) i3's dmenu .

  • FancyZones: For snapping window management. Includes some keyboard control, but definitely doesn't have the auto-tiling that I'm sure you love from i3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM