wsl 2, the version you are running, makes the X11 display configuration harder, but it works. I have included some notes on this, but you can also consider switching to wsl version 1, where the X11 configuration was simpler.
X11 server had some problems. VcxSrv worked with the following changes (Native opengl off, Disable access control on). The settings can be saved as an XLaunch configuration to the Desktop and launched from the configuration for future starts.
Also must set DISPLAY in Ubuntu terminal. This is different from WSL1.
export DISPLAY="$(/sbin/ip route | awk '/default/ { print $3 }'):0"
The /sbin/ip router seems more reliable than the "dig" command method that is also posted elsewhere. The same IP address that gets used also appears in the output of "ipconfig.exe" (DOS style name in Linux is strange) in the Ubuntu terminal.
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : xxx
IPv4 Address. . . . . . . . . . . : 192.168.1.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter vEthernet (WSL):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : xxx
IPv4 Address. . . . . . . . . . . : xxx.xx.xxx.xx
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
So this command should work too using that output:
export DISPLAY=$(ipconfig.exe |grep -A 4 WSL | tail -1 | awk -F: '{print $2}'|tr -d '[:space:]'):0
X11 seems very slow to start here, but works okay when it starts. suma doesn't seem to work as well with VcxSrv though.
MobaXterm seems a little faster, and suma works pretty well. It now requires some babying, instead of working just out of the box. And it requires accepting in a couple windows connections across the virtual network adapter from the WSL side into the Windows side.
export DISPLAY="$(/sbin/ip route | awk '/default/ { print $3 }'):0"
Click "Yes" to accept. Note the IP address in the message is different from both the previous ones used here. To avoid this warning message, do as the window says and change MobaXterm settings and set X11 remote access to full instead of "on-demand".
Also another note, once MobaXterm starts, it acts as an Xserver too. Even Ubuntu terminal shells can use this with similar DISPLAY settings.
I expect that a couple other Xservers will work too - Xwin32, X410.
Some related links:
[
www.reddit.com]
[
x410.dev]
Edited 1 time(s). Last edit at 11/30/2020 10:10AM by Daniel Glen.