Skip to content

Instantly share code, notes, and snippets.

@djfdyuruiry
Last active March 7, 2024 03:41
Show Gist options
  • Save djfdyuruiry/3150b9e5f3dadba89ea323df49ea7ab1 to your computer and use it in GitHub Desktop.
Save djfdyuruiry/3150b9e5f3dadba89ea323df49ea7ab1 to your computer and use it in GitHub Desktop.

Revisions

  1. djfdyuruiry revised this gist May 29, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # WSL 2 XServer Setup

    This guide will setup WSL 2 to be able to connect to an XServer installed on your host Windows machine. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2. The XServer software used was [VcXsrv](https://sourceforge.net/projects/vcxsrv/); remember to disable authentication for this to work correctly.

    - Open a WSL terminal
  2. djfdyuruiry revised this gist May 29, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    This guide will setup WSL to be able to connect to an XServer installed on your host Windows machine. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2. The XServer software used was [VcXsrv](https://sourceforge.net/projects/vcxsrv/); remember to disable authentication for this to work correctly.
    This guide will setup WSL 2 to be able to connect to an XServer installed on your host Windows machine. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2. The XServer software used was [VcXsrv](https://sourceforge.net/projects/vcxsrv/); remember to disable authentication for this to work correctly.

    - Open a WSL terminal

    @@ -19,7 +19,7 @@ This guide will setup WSL to be able to connect to an XServer installed on your
    export DISPLAY="${WSL_HOST}:0"
    ```

    - Reopen a terminal and prove it works:
    - Close and reopen the terminal and prove it works:

    ```bash
    sudo apt-get install -y x11-apps
  3. djfdyuruiry created this gist May 29, 2020.
    27 changes: 27 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    This guide will setup WSL to be able to connect to an XServer installed on your host Windows machine. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2. The XServer software used was [VcXsrv](https://sourceforge.net/projects/vcxsrv/); remember to disable authentication for this to work correctly.

    - Open a WSL terminal

    - Fix an issue with `dbus`:

    ```bash
    sudo sh -c "dbus-uuidgen > /etc/machine-id"
    ```

    - Update `~/.zshrc`:

    ```bash
    # X Server
    export $(dbus-launch) # not needed if you have systemd enabled
    export LIBGL_ALWAYS_INDIRECT=1

    export WSL_HOST=$(cat "/etc/resolv.conf" | grep nameserver | awk '{print $2}' )
    export DISPLAY="${WSL_HOST}:0"
    ```

    - Reopen a terminal and prove it works:

    ```bash
    sudo apt-get install -y x11-apps
    xeyes
    ```