4

I'm using WSL2 with Ubuntu 20.04 on Windows 11. I've noticed that when you open a GUI app like xmGrace or Gnuplot, WSLg opens the GUI app through the "Remote Desktop Connection". So Xming is not used even I've installed it. The problem is that the GUI interface of WSLg has several issues -- For example, the top menu bar in xmGrace doesn't work at all. Also gnuplot has similar problems.

On Cygwin, Xming is used and both apps work perfectly. Is it possible for WSL to use Xming instead of WSLg on Windows 11?

NotTheDr01ds
  • 28,025

1 Answers1

6

Short answer:

Try running:

export DISPLAY="$(hostname).local:0"

That should allow xmgrace and gnuplot (and any other X client) to utilize Xming.

Explanation:

You should still be able to use Xming with WSL2 even on Windows 11, but you'll need to set the DISPLAY variable appropriately in order to make sure that X clients (e.g. xmgrace, gnuplot) display on the appropriate X server.

By default on Windows 11 with WSLg, DISPLAY=:0, which sends the traffic to localhost:0 where the X socket in /tmp/.X11-unix is symlinked to the WSLg X socket (which, as you've noticed, uses RDP with RAILS).

Since WSL2 runs inside a virtual network which is separate from the Windows network, you'll need to point DISPLAY to an interface on the Windows network. This interface can be found using the mDNS name for the Windows machine, which is typically the "computer name" + ".local". Under WSL, that's typically "$(localhost).local".

If that fails for some reason, try the more unwieldy version:

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
NotTheDr01ds
  • 28,025