###### tags: `FRC`
# Using Graphical User Interface in WSL
>2022/7/29
---
First check your OS version
## windows 11
Follow the instruction in the link below:
https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

---
---
## windows 10: Use VNC server
1. Open wsl and run update before everything starts.
```cmd
sudo apt update
```
2. Install XFCE desktop environment on your ubuntu WSL.
```cmd
sudo apt install xfce4 xfce4-goodies
```
3. Install TightVNC.
```cmd
sudo apt install tightvncserver
```
4. Then launch VNC by typing:
```cmd
vncserver
```
After launching, you will be asked to set a password which is used to verify the identification during connecting.
==Note: password over 8 characters will be trimed to 8.==

Once you will be asked to enter a view-only password, chose n.
View-only mode gives users limited access such as no keyboard and mouse functionality.

When all set up, run:
```cmd
echo "startxfce4 &">~/.vnc/xstartup
```
Which will add ```startxfce4 &``` at the end of the file.
(OPTIONAL) Use ```sudo nano ~/.vnc/xstartup``` command to check the file is changed or not.
5. Your IP address and local address are required for connecting, use:
```cmd
ifconfig
```
and
```cmd
netstat -lntp
```
commands and note them down as marked in the following images.


6. Starting VNC in WSL is not as same as a regular Ubuntu machine, we need to use starting script to cover the work.
Run:
```cmd
nano ~/vncstart.sh
```
Then add the following contents in the file:
```cmd=
#!/bin/bash
vncserver -kill :1 > /dev/null 2>&1
rm -f /tmp/.X1-lock
rm -f /tmp/.X11-unix/X1
vncserver :1 -geometry 1366x768
```
After save and close the file, run:
```cmd
chmod u+x ~/vncstart.sh
```
to give the execution rights.
---
Last, run:
```cmd
./vncstart.sh
```

7. Install VNC Viewer on your PC
https://www.realvnc.com/en/connect/download/viewer/
8. In VNC viewer, eneter the address in step 5, combine them with ```:``` and then press enter.

Enter the password you set in step 4.

9. Enjoy your WSL GUI!
