Linux – Do I launch the app XLaunch for every login to use GUI in Ubuntu WSL in windows 10 pro

guiUbuntuwindowswindows-subsystem-for-linux

I have Ubuntu 18.04 LTS WSL in y Windows 10 pro. To set graphic user interface in Linux bash shell I installed XLaunch. But to use GUI in my WSL for every login in my pc I need to launch XLaunch. Is it possible some how to launch XLaunch once and it remains as long as I use bash shell in windows 10.

Thanks,

Best Answer

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).

-multiwindow
Run the server in multiwindow mode.

-clipboard
Enable [disable] the clipboard integration. Default is enabled.

-wgl
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.

  1. 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.

vcxsrv_shortcut

Then put that shortcut in %AppData%\Microsoft\Windows\Start Menu\Programs\Startup folder to automatically start VcxSrv when PC boots up.

  1. 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.

Related Question