Skip to content

Instantly share code, notes, and snippets.

@jaredswarts55
Created May 7, 2020 16:12
Show Gist options
  • Save jaredswarts55/1472735480b7f87caf61848a5c8f8556 to your computer and use it in GitHub Desktop.
Save jaredswarts55/1472735480b7f87caf61848a5c8f8556 to your computer and use it in GitHub Desktop.

WSL 2 Setup

On the wsl 2 run

sudo apt update
sudo apt install xubuntu-desktop

I received an error about blueman, the bluetooth manager? and ignored it.

Add the following two lines to the end of ~/.bashrc

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

Host Machine Software Setup

  1. Download the pulse audio windows binary release and unzip it: https://www.freedesktop.org/wiki/Software/PulseAudio/Ports/Windows/Support/
  2. Download and install VcXsrv

Pulse Audio Setup

Some of the configuration files need to be changed to run pulse audio correctly

Pulse Audio default.pa Changes

In the unzipped pulse-audio folder go to etc\pulse and edit default.pa, replace the line

load-module module-waveout sink_name=output source_name=input

with

load-module module-waveout sink_name=output source_name=input record=0

and replace the line

load-module module-native-protocol-tcp 

with

load-module module-native-protocol-tcp auth-anonymous=1

Pulse Audio system.pa Changes

Not sure these changes were neccessary In the unzipped pulse-audio folder go to etc\pulse and edit default.pa, replace the line

load-module module-native-protocol-unix

with

load-module module-native-protocol-unix auth-anonymous=1

Pulse Audio daemon.conf Changes

In the unzipped pulse-audio folder go to etc\pulse and edit daemon.conf.

Uncomment exit-idle-time and set it to -1 like so:

exit-idle-time = -1

Setup VcXsrv

Just involves creating a config.launch file with the following contents

<?xml version="1.0" encoding="UTF-8"?>
<XLaunch WindowMode="Windowed" ClientMode="NoClient" LocalClient="False" Display="-1" LocalProgram="xcalc" RemoteProgram="xterm" RemotePassword="" PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="" XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True" ClipboardPrimary="True" ExtraParams="-swcursor -ac" Wgl="True" DisableAC="False" XDMCPTerminate="False"/>

Running it all

On the host machine, I have a batch file with the following contents that I run:

start /B config.xlaunch
start "" /B "C:\bin\pulseaudio-1.1\bin\pulseaudio.exe"

On the wsl 2 terminal, I just run:

xfce4-session

The above command only works if the .bashrc was run, setting those environment variables. You will need to open a new wsl2 terminal to get it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment