ACTONDEV Development, philosophy, writing

Setting up WSL2 xserver display
2019-11-11

WSL2 DISPLAY xserver

TL;DR

add this line to your ~/.bashrc file (in the WSL2 machine)

export DISPLAY="$(cat /etc/resolv.conf | grep -Po "nameserver \K[0-9.]+"):0"

And install VcXsrv in your windows machine

Windows host IP

The windows host ip can be found by running

cat /etc/resolv.conf

This gives something like

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.20.112.1

Now, to programmatically get this ip we run

cat /etc/resolv.conf | grep -Po "nameserver \K[0-9.]+"

Comments

Leave your comments below