I have a python game that is being run on wl2 and I would like the display to be in windows. I have tried to use the code below in my python program but it just gets stuck because it is not the correct display. I have also checked out this question but it did not seem to be an answer I could apply to this project. I could just run this program in windows but that causes a whole lot of other problems and will probably have to be in another question. Any help would be greatly appreciated!
I wish I could share the program but unfortunately it’s for a ctf and should not be posted :(
I used this question for reference to the code below:
import os os.environ["SDL_VIDEODRIVER"] = "dummy"
With the above code (seems to be working but nothing shows up):
Advertisement
Answer
Audio
You can not redirect audio (ALSA) with WSL2. You could still try something streaming with ffmpeg from linux to windows.
Graphics
Setup an X server on your windows host and provide a DISPLAY environment variable on WSL to it, e.g.
DISPLAY=172.24.144.1:0
On WSL2 localhost
or 127.0.0.1
unfortunately does not work, so you have to check your machine adapter addresses on Windows side.
There are plenty of them. I used very simple (and handy) Xming X Server for Windows aka XLaunch.
This one is compatible with opengl X11 drivers.
UPDATE
You can nicely automate setting properly DISPLAY
variable by adding this line to the ~/.bashrc
file in your WSL2 machine:
export DISPLAY=`grep -oP "(?<=nameserver ).+" /etc/resolv.conf`:0.0