WSL configuration
Install i3
sudo apt install i3 -yCreate an init script
vim ~/src/scripts/i3launch.sh
#!/bin/zsh
source ~/.zshrc
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1
dbus_status=$(service dbus status)
if [[ $dbus_status = *"is not running"* ]]; then
sudo service dbus --full-restart
fi
i3
To run WSL2 as root
wsl.exe -d Ubuntu-20.04 -u root -- /bin/bash
Windows configuration
Install
vcxsrvfrom powershellwinget install vcxsrv
With WSL2 you need to configure your firewall to allow WSL and vcxsrv to communicate.
Search for Windows Defender Firewall with Advanced Security and do the following:
Create an inbound rule:
name: wsl2 rule type: port port type: tcp port number: 6000Narrow the scope of your inbound rule:
Right click -> Properties -> scope -> Remote IP addresses -> Add 172.16.0.0/12Search for
VcXsrv windows xserverinbound rules and make sure the 4 rules areenabledand inallowmode

Startup i3 script from Windows
vcxsrv.vbscode vcxsrv.vbs
Set shell = CreateObject("WScript.Shell" )
shell.Run """C:\Program Files\VcXsrv\vcxsrv.exe"" :0 -screen 0 @1 -ac -engine 1 -nodecoration -wgl"
WScript.Sleep 200
shell.Run "wsl.exe -d YOUR_DISTRO -u YOUR_USER -- /bin/zsh ~/src/scripts/i3launch.sh", 0
And just run your script from powershell
.\vcxsrv.vbs
You should see this screen.

i3 configuration
Up to you.