Required
GUI
Optional
Some time ago, you would need to have a complicated, convoluted and unreliable setup for using GUI apps within WSL. Thankfully, we now have WSLg, which transforms this whole ordeal into a non-pain-in-the-butt experience.
Wayland & X11
If you use the “official” Distribution, i.e. Ubuntu, it should also work out of the box. As we use ArchWSL, we have to setup the correct symlinks though.
-
The environment variables should already be automagically setup to the correct values at this point.
Terminal window $env.WAYLAND_DISPLAY = 'wayland-0'$env.DISPLAY = ':0'$WAYLAND_DISPLAY = 'wayland-0'$DISPLAY = ':0' -
Everything we need, should already be in
/mnt/wslg
, namelyruntime-dir
and.X11-unix
-
Create a
systemd
service that setups the Wayland runtime directory/etc/systemd/user/wslg-runtime-dir.service [Service]Type=oneshotExecStart=sh -c "ln -fs /mnt/wslg/runtime-dir/* "%t[Install]WantedBy=default.target -
Create a
systemd
service that setups the X11 socket/etc/systemd/user/wslg-X11-unix.service [Service]Type=oneshotExecStartPre=rm -rf /tmp/.X11-unixExecStart=ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix[Install]WantedBy=default.target -
Enable those services
Terminal window sudo systemctl --global enable wslg-runtime-dirsudo systemctl --global enable wslg-X11-unix -
Restart WSL
Terminal window exitTerminal window wsl.exe --shutdownarch.exe
OpenGL
For me it seem that installing mesa was enough to make e.g. CadQuery run without problems.