One of the more exciting pieces of tech coming out of Microsoft these days is the Windows Subsystem for Linux (also sometimes referred to as "Bash on Ubuntu on Windows"). If you haven't heard of it yet, you should definitely check it out.
Today, we'll talk about setting up an aesthetically-pleasing graphical development environment within it.
The Windows Subsystem for Linux (henceforth WSL) allows ELF binaries to run unmodified on top of Windows, within an Ubuntu-based environment. The catch here is that WSL is not a virtual machine, but rather a shim that maps x64 Linux syscalls to their NT equivalents, or, where they don't exist (as in the case of
fork(2), for example), to more complex logic emulating them. That is, there is no real virtualization taking place here, which is great — it means WSL binaries run at near-native speed, with no extra memory overhead.
After you've installed WSL, you are greeted with a functional
bash prompt and some default userland binaries. This is already technically impressive, but can we push it further? Can we run an environment that is both graphical and looks nice? It turns out that without too much effort, we can.
In /r/unixporn fashion, what you see above is:
- OS: Ubuntu 16.04 running in WSL, Windows 10 Anniversary
- WM: i3-gaps@fdf5d3a (later versions seem to have issues on WSL)
- Bar: polybar + a patch to get the memory widget working nicely in WSL (and older kernels in general), which is now merged back into master.
- Launcher: rofi
- Terminal: Terminator edited to behave like PuTTY (right click paste, Ctrl+right click settings). The shell is bash, and the colors are Terminator's defaults — I like both.
- Wallpaper: 6 sets of day/afternoon/night background images from a visual novel I really like, alternating every 10 minutes. Wrote a script to extract them and upscaled with waifu2x, since I don't own a PS4 to take screenshots with. Controlled by a Python script using PyEphem to determine whether it's day, night, or afternoon, given GPS coordinates. Mandatory credit for the idea.
- GTK Theme: Numix or Numix dark, depending on time of day (controlled by wallpaper script).
- X Server: VcXsrv running in root window mode, configured to have an Ubuntu icon in tray. (Unfortunately I couldn't get the actual taskbar icon to be one too.) I've heard horror stories of VcXsrv crashing for people using WSL, but I haven't had any issues with it.
- Compositor: compton really helps with some tearing otherwise experienced. It also makes polybar transparent, which I guess is cool.
- Audio: Works via pulseaudio looped over localhost TCP back into Windows, with this patch applied to fix pulseaudio under WSL.
If you're in a hurry, you can check out the dotfiles for this from here.
The speed is more than satisfactory: I run a 4K display and don't notice any input latency under normal conditions (editing and browsing files). It's likely that VcXsrv might start struggling with frequent full-screen repaints (
cmatrix or videos, for example), but those don't happen under my regular workload.
I have been using this setup day-to-day for nearly half a year now, and am really enjoying it. Once upon a time, I used to have dozens of
python windows open; this WSL setup allows me to have them all neatly organized inside i3 workspaces confined to a single VcXsrv window.