Windows/WSL

From Segfault
Jump to navigation Jump to search

Installation

The Windows Subsystem for Linux Installation Guide for Windows 10 are pretty staightforward, but let's summarize them anyway. As an administrator in a PowerShell window:

cd c:\temp
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Download[1] a Linux distribution, for example Ubuntu 18.04:

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing

Install with:

Add-AppPackage .\Ubuntu.appx

The noisy terminal bell can be disabled[2] via /etc/inputrc:

set bell-style none

Sound

For some reason we needed sound support in our WLS environment. Another blog explained how to do this[3] but we only need sound on the command line, so we can omit some parts. The important steps are:

  • Download a precompiled pulseaudio binary from freedesktop.org
  • Extract and edit a two files before we can start it:
etc\pulse\default.pa
load-module module-waveout sink_name=output source_name=input
load-module module-waveout sink_name=output source_name=input record=0

#load-module module-native-protocol-tcp
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
etc\pulse\daemon.conf
; exit-idle-time = 20
exit-idle-time = -1
  • With that, pulseaudio.exe should be able to start and will now listen on localhost
  • For our needs, all we needed to do was to point our music program (in WSL) to the Pulseaudio server (running in Windows):
export PULSE_SERVER=tcp:127.0.0.1
mpg123 file.mp3

Other programs may need other hints to connect to the Pulseaudio server though.

References