Ubuntu on WSL: X and sound server detection explained

When I started using Ubuntu more than a decade ago I was impressed how well it worked out of the box. It detected most of my machine’s hardware and I could start working on it immediately. The Windows Subsystem for Linux is a much newer Ubuntu platform which can also run graphical applications without any extra configuration inside Ubuntu.

If you set up and start an X server or a PulseAudio server on Windows and start Ubuntu in WSL, the starting Ubuntu instance detects the presence of the servers and caches the configuration while the instance is running. The detection takes a few hundred milliseconds at the first start in the worst case, but using a cached configuration is fast and the delay is unnoticeable in subsequently started shells.

The detection is performed by /etc/profile.d/wsl-integration.sh from the wslu package and the configuration is cached in $HOME/.cache/wslu/integration.

If you would like to use a different X or sound configuration, like redirecting graphical applications to a remote X server you can prepopulate the cached configuration with a script running before /etc/profile.d/wsl-integration.sh or you can disable the detection logic with a similar script by making $HOME/.cache/wslu/integration an empty file.

2 thoughts on “Ubuntu on WSL: X and sound server detection explained

  1. Vincent Bernat

    Hey!

    The unset at the end of the script doesn’t match the variable at the top.

    Reply
  2. Edgar Martinez

    Hi. I want to thank you for this article.

    I’ve managed to get WSL running, and after some hassle installed a lot of working packages. I even have gnome running on GUI with xming and systemd.

    What i really want to try is installing audio. It’s really dumb trying to fix audio specially since everything is supposed to be working.

    But whenever I try to run pavucontrol from the terminal it shows me that it can’t open display. But when i search for it on gnome it opens through gui fine. I tried moving the settings but i haven’t’ been able to make the sound work.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.