Responsive image
Date 2022-10-12 15:00

UPDATE: As of Summer of 2023, if you update WSL2 to the latest update, you NO LONGER need vcxsrv or similar applications to do this!


Recently I've upgraded from Windows Subsystem for Linux v1 (WSL1) to WSL2 and in the process I had to change how I launch xfce4-terminal on Windows 10.

This post is to document what I'm doing after a reboot when I want to run xfce4-terminal (or any other terminal for that matter) natively on Windows 10.

This assumes you have installed vcxsrv and WSL2.

  1. Launch Windows Terminal
  2. Run wsl -d Ubuntu (or whatever the name of your distribution/installation is)
  3. Open a separate tab and run ipconfig
  4. Write down the IPv4 address for the "Ethernet adapter vEthernet (WSL)"
  5. Go back to your tab that launched your WSL2.
  6. Edit the following script and replace the IP address with what you wrote down from the output of ipconfig:
    1. For extra security generate a random text for the part immediately after echo.
export DISPLAY=172.XX.XX.1:0
mv ~/.Xauthority ~/.Xauthoritybak
touch ~/.Xauthority
magiccookie=$(echo 'CHANGEME'|tr -d '\n\r'|md5sum|gawk '{print $1}')
xauth add "$DISPLAY" . "$magiccookie"
cp ~/.Xauthority /mnt/c/Users/yano/.Xauthority
  1. Save the script as set_xauthority.sh and chmod +x set_xauthority.sh
  2. Run ./set_xauthority.sh
  3. Now switch gears and create a Windows 10 Shortcut
  4. Set the "Start In" to be: C:\WINDOWS\System32\WindowsPowerShell\v1.0
  5. Set the "Target": C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -Command "wsl -d Ubuntu -e bash -c \"export DISPLAY=172.XX.XX.1:0; xfce4-terminal\""
  6. Change the IP address to match the IP address from the output of ipconfig

  7. Now, Launch vcxsrv

    1. When prompted for "Select display settings", select Multiple Windows.
    2. Select "Display Number" as -1.
    3. Click Next.
    4. Select "Start no client" and then click Next.
    5. On the page for "Extra Settings," make sure the following are checked:
      1. "Clipboard"
      2. "Primary Selection"
      3. "Native opengl"
    6. Leave "Disable access control" unchecked.
    7. Click Next.
    8. Enter "C:\Users\yano.Xauthority" in the parameters textbox.
    9. On the "Configuration complete" page, you may choose to save it or just click Next.
  8. Now you should be able to launch your new shortcut you created.


Comments

comments powered by Disqus

where randomness meets the internet


~ About me ~
just a human doing random things
~ Follow me ~