Skip to content

Instantly share code, notes, and snippets.

Created January 19, 2022 02:32
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Run desktop applications under WSL and display them with VcXsrv

First setup:

  • Install VcXsrv (

  • Launch it (shows up in windows search as "XLaunch"), it will prompt you for some configuration

    • "Select display settings" sets how you want your WSL applications to be presented on the desktop, set these options however you like
    • "Select how to start clients" can be left at "Start no client"
    • On the "Extra settings" screen, tick "Disable access control" (or, if you don't trust your local network, have fun figuring out X authorities I guess)
    • Save your configuration to a file - this will be handy later
  • Once you click "Finish", head to WSL and check /etc/resolv.conf. Copy down the IP in the nameserver line - that's the IP you can use in WSL to target normal Windows

  • In WSL bash, export DISPLAY="IP:0" where IP is the one you just found

  • Try running a GUI application - for example, xeyes (sudo apt install xeyes if you don't have it)

xeyes working from wsl!

To speed things up in the future:

  • If you saved your XLaunch settings to a file, you can use them automatically by modifying the XLaunch application shortcut. Add the option -run "C:\Path\To\config.xlaunch" to the "Target" box in the shortcut's properties.

  • You can automatically set $DISPLAY from your shell profile. For example, I use the following for bash/zsh:

    # If on WSL, define DISPLAY with the local system address from /etc/resolv.conf to enable GUI stuff
    if [ -n "$WSL_DISTRO_NAME" ]; then
        export DISPLAY="$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment