If we should ever decide to change from the WSL1 to the WSL2, we have to fix the DISPLAY config.
Currently we use
echo "export DISPLAY=localhost:0.0" >> ~/.bashrc
to setup the connection to the XDisplay.
Since the WSL2 <superficial knowledge> has its own kernel and is not just a layer of some kind it has its own IP address and
</superficial knowledge> we cant use localhost anymore.
I found this neat grep command to get the IP address from a file in the WSL2 filesystem:
grep -oP "(?<=nameserver ).+" /etc/resolv.conf
This localhost in the above settings can be substituted by this grep command to fix the problem:
I had to look up this grep command so here is a small summary of the full story if someone is interested as well:
-o shows only the matched characters and not the whole line
-P switches to perl-regex
(?<=nameserver ).+ is a regex called positve lookbehind (only available with perl-regex)
it matches anything (.+: atleast on character) after an occurance of nameserver without matching it as well
/etc/resolve.conf contains the IP address, the line of interest contains nameserver 123.45.678.9
If we should ever decide to change from the WSL1 to the WSL2, we have to fix the
DISPLAY
config.Currently we use
to setup the connection to the XDisplay. Since the WSL2
<superficial knowledge>
has its own kernel and is not just a layer of some kind it has its own IP address and</superficial knowledge>
we cant uselocalhost
anymore.I found this neat
grep
command to get the IP address from a file in the WSL2 filesystem:This
localhost
in the above settings can be substituted by thisgrep
command to fix the problem:I had to look up this
grep
command so here is a small summary of the full story if someone is interested as well:-o
shows only the matched characters and not the whole line-P
switches to perl-regex(?<=nameserver ).+
is aregex
called positve lookbehind (only available with perl-regex) it matches anything (.+
: atleast on character) after an occurance ofnameserver
without matching it as well/etc/resolve.conf
contains the IP address, the line of interest containsnameserver 123.45.678.9
⇒ the result of the
grep
command is123.45.678.9