I have a WSL2 with ubuntu 20. In most posts, setting up DISPLAY environmental variable to access windows X11 server is made through WSL localhost address in ~/.bashrc
$ export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0or
$ export DISPLAY=$(cat /etc/resolv.conf |grep nameserver| sed 's/nameserver //'):0However, these commands will find the WSL2 machine localhost IP that differs from host machine localhost.
For Me, to make xlaunch X11 server works properly, I have to set DISPLAY every time the host localhost IP is changed using cmd ipconfig command.
Is there a way to set DISPLAY to host machine localhost before the start of WSL2. For instance, through windows %USERPROFILE%\.wslconfig file.