윈도우의 WSL2 위에 WSLg 기능을 설치하면, VcXsrv 등의 프로그램 없이도 리눅스용 GUI 프로그램들을 실행할 수 있다.
If we install WSLg on the Windows WSL2, we can run GUI programs for Linux without programs such as VcXsrv.
$ wsl --update
$ wsl --shutdown
$ wsl
종종 cannot open display (또는 couldn’t open display) 등의 에러가 뜨며 GUI 프로그램이 실행되지 않는 경우가 있다. 이 때는 아래 사항들을 체크해 보면 된다.
Sometimes we get an error such as cannot open display (or couldn’t open display) appears and the GUI program may not run. In this case, we can try the following methods.
(1) .wslconfig
notepad $env:USERPROFILE/.wslconfig 입력notepad $env:USERPROFILE/.wslconfig on PowerShell(2) DISPLAY
echo $DISPLAY를 실행했을 때 :0이 출력되는지 확인~/.bashrc 등에 export $DISPLAY=... 등 DISPLAY를 덮어씌우는 문장이 있는지 확인
echo $DISPLAY on wsl and check whether the output is :0~/.bashrc and check whether there are lines which overrides DISPLAY (ex. export $DISPLAY=...)(3) .X11-unix
sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix 실행
sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix(4) XDG_RUNTIME_DIR
echo $XDG_RUNTIME_DIR을 실행했을 때 /mnt/wslg/runtime-dir이 출력되는지 확인~/.bashrc에 export $XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir 적어주기
echo $XDG_RUNTIME_DIR on wsl and check whether the output is /mnt/wslg/runtime-direxport $XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir on ~/.bashrc