Let have some background first. To configure general X11 connection, we have to set the
DISPLAY variable in WSL with this command
export DISPLAY=:0. Also don't forget to use this
export LIBGL_ALWAYS_INDIRECT=1 command which enables direct rendering. If these were done then go to the next step: configuring VcxSrv.
VcxSrv has many command line options (XWin man page). You can get the option details with
vcxsrv.exe --help command. For WSL, mainly three options are required (can be changed).
Run the server in multiwindow mode.
Enable [disable] the clipboard integration. Default is enabled.
Enable the GLX extension to use the native Windows WGL interface for hardware-accelerated OpenGL.
The command will be:
vcxsrv.exe :0 -multiwindow -clipboard -wgl.
Now the final step is to launch it before WSL launches. There may be multiple ways to do this. Here I mention two of them.
- Create a shortcut with that previous command. You should mention the full path in that command. e.g.
E:\VcXSrv\vcxsrv.exe :0 -multiwindow -clipboard -wgl. Here is a screenshot.
Then put that shortcut in
%AppData%\Microsoft\Windows\Start Menu\Programs\Startup folder to automatically start VcxSrv when PC boots up.
- Another way is to add the full command in registry with this command as administrator:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V VcxSrv /D "E:\VcXSrv\vcxsrv.exe :0 -multiwindow -clipboard -wgl"
Follow any one of the above two methods, not both.
VcxSrv.exe will launch when you restart your PC.