DEV Community

fquinner
fquinner

Posted on

Windows 10 as a Linux Window Manager with WSL2

So on Windows 10, this is how I roll

Windows Toolbar for Linux Demo

Yes those GUI windows are all Linux apps.

Why in the name of all that is Sacred?

Well it's actually not that complicated. I love Linux. I really do. Always have, always will. If it was my choice, I would never touch Windows because it's just not as developer friendly, and I'm a professional developer.

But..?

But sometimes you want to run Office. And sign on to corporate services. And... you know... print and screencast during meetings. Although you can usually do all of those things on Linux, it usually involves more effort than I'm willing to invest these days. Not because of Linux, I hasten to emphasize, but because Windows and (occasionally) Mac are the only operating systems that most peripheral vendors care about these days. Which means things tend to work out of the box. And this is a productivity machine after all.

So this is just another WSL tutorial?

Not quite... it's more of a brain dump of what I did, the project that I maintain, and how you can run every Linux UI application in a sensible way alongside windows. This particular solution is focused on WSL 2, but will also work on WSL 1.

I won't be doing a hand-holding tutorial (not at this point at least). This is more of a show and tell / introduction to my toolbar project.

And the catch?

This solution does not seem to play nicely with resume from suspend / hibernate... however a workaround for this does exist, which I may write about later...

How do I get access to this wizardry?

I'll not get into the details here but it's all documented on the github repository (which you are welcome to star). If you can't get it working, raise and issue and I'll help if I can.

Why did you set this up?

I started the project because I use C applications that target a linux environment a lot and although remote development has come a long way, it is still in my opinion pretty awful. Things like debuggers misbehaving, sessions getting scrambled, synchronization breaking, plugins not working when remote etc always seem to be there (for me at least). So this is effectively local linux development on windows. Or more practically, using Windows as a window manager for Linux.

Since WSL 2 in particular this was a big deal. With WSL 1 many things worked but not everything. WSL 2 looks and feels like proper linux and you always have much more confidence that your stuff will run well than you ever had with WSL 1.

At first I searched for a tool to let me launch WSL Linux GUI applications more natively from Windows and there are things for creating shortcuts etc. but they all seemed to be a little hacky for my taste.

So I started writing the project (which literally just generates windows shortcuts to WSL commands) and posted it to twitter with a few hashtags, created a reddit post, and answered a stackoverflow answer or two pointing to the repository.

To my surprise since it's launch almost a year ago it is up to 250 stars on Github, it is regularly downloaded in pypi and it's definitely in active use since I get issues raised regularly and even some contributions back!

Wrapping up

This is my first post to dev.to so please be gentle... but the story here is not so much a "build it and they will come" story. Because all too often they don't come at all!

It's just a story of what I did - I wanted a problem solved, I solved it, I shared it, and now others use it too. And it feels pretty cool I highly recommend it - even if they don't come :).

Top comments (20)

Collapse
 
jameslivesey profile image
James Livesey • Edited

Nice setup! A warm welcome to dev.to, too. What's your thought on just virtualizing Windows inside of Linux? I whipped up Win10 and macOS Big Sur and it works perfectly — the integration really works well. And I don't have to deal with Windows updates 100% of the time!

Collapse
 
fquinner profile image
fquinner

Thanks! Yeah unfortunately I would actually personally prefer the Windows window manager over OSX, you end up needing to use brew which often conflicts with native packages etc. And in real terms in my environment it feels like Linux under the hood and I literally only use Windows as a window manager. I even have windows terminal set up to launch WSL by default and run ssh etc from there (no putty), symlinks to Downloads folder and Desktop to make it feel super integrated but I'll maybe write about those another time ;)!

Collapse
 
trusktr profile image
Joe Pea

That seems like a lot more work than running WSL in Windows, or Cristini Linux in Chrome OS. Your setup might work, but it costs time.

I love how simple it is to buy a Chromebook, flip an option to true, and now I can run any Linux apps installed with apt. It's the no hassle that is worth the value.

Collapse
 
jameslivesey profile image
James Livesey

Very true, coming from a Chromebook owner myself! Crostini is great now that it's (relatively) stable. I was considering putting Chromium OS/CloudReady on my main PC, but instead I opted for Debian as it gives me much more customisability in terms of desktop environment etc.

Collapse
 
rwilliams profile image
Ron Williams

Cool setup. I was investigating the suspend resume issues with a similar setup. When you said there was a workaround were you referring to github.com/nbdd0121/x11-over-vsock?

Collapse
 
fquinner profile image
fquinner

That's one of them yeah :). You can also do stdout buffering I haven't decided which is faster but they both work!

Collapse
 
rwilliams profile image
Ron Williams

Can you point me in the right direction to start playing with stdout buffering?

Thread Thread
 
fquinner profile image
fquinner • Edited

Sure, first of all you find one of the socat ports for windows, download it, then run:

socat UNIX-LISTEN:/tmp/.X11-unix/X0,fork EXEC:"/mnt/c/tools/socat/socat.exe - TCP\:localhost\:6000
Enter fullscreen mode Exit fullscreen mode

Original source: github.com/microsoft/WSL/issues/46...

Good luck!

Thread Thread
 
rwilliams profile image
Ron Williams

Thanks for the tips on this. I got this up and running after a bit of fiddling. I've decided on the socat solution with the WSL1 pass through, as the performance was terrible when using the windows port of socat. Apps load instantaneously and it's robust across sleeps and network connection changes like x11-over-vsock.

Thread Thread
 
fquinner profile image
fquinner

Yeah that's my setup too :). Can't wait to have proper wayland support then we wont need any of that and it'll be even snappier :)

Collapse
 
tehmoros profile image
Piotr "MoroS" Mrożek • Edited

It's true. The real window manager in this setup is the X11 server running on Windows (it's this piece of the puzzle making the shots to Windows API). It's actually quite easy to set up though (install and launch on Windows, set the DISPLAY environment variable in WSL). It has it's cons though: forget cross-developing OpenGL apps in that manner. The best you get is OpenGL 1.4, which is very basic.

Still, that toolbar integration is quite nice and useful. :)

Collapse
 
fquinner profile image
fquinner

It's a window manager in the sense that Gnome is a window manager or KDE is a window manager or (my beloved and preferred) i3 is a window manager. May be technically debatable but it's a common use of the term (i3's domain name is i3wm.org where wm stands for "window manager", but it sits on top of X11 too).

In this instance, I'd call X11 the window server, but Windows is still the window manager for the system. Those are still Windows'... well... windows. They'll show up with alt + tab etc. and they'll appear in the toolbar. The communication with WSL is via X11 protocols though.

And it's cool - Wayland is coming which should provide more options too - this is merely a convenience script to make launching feel more native :)

Thread Thread
 
tehmoros profile image
Piotr "MoroS" Mrożek

Agreed. :) I didn't want to go into too much detail and it came out a bit different than what I meant.

Collapse
 
jimmymcbride profile image
Jimmy McBride

If you figure out how to run windows on a Linux window manager, let me know. Windows desktop environment is my number 1 biggest turn off. Lol

I would use windows a lot more if I could get a tiling manager or gnome on there.

Collapse
 
sp96296 profile image
Evan H

I like the Destiny loading background. Another reason why I cant spend 100% time in linux, love this post.

Collapse
 
fquinner profile image
fquinner

The wallpaper is from another pet project that I have neglected in a long time - porting Variety for Linux to Windows ;) github.com/varietywalls/variety/pu...

Collapse
 
_hs_ profile image
HS

I'm getting a feeling it will end by Windows being more lika macOS but instead of direct Unix core it will be Linux. However even if my feeling's right, I don't think it will happen anytime soon, more like 3+ years.

Collapse
 
sp96296 profile image
Evan H

Just a heads up to people who have a custom WSL2 setup
I run Arch and had to install lib32 cairo. You can install from pacman -Ssq lib32 or pacman -Ssq lib32 | pacman -S -

Collapse
 
fquinner profile image
fquinner

Thanks! I'm sure it'll help someone!

Collapse
 
alwan_rosyidi profile image
Alwan Rosyidi

This really depends on your preference.

I'm Linux & FOSS person. I will install Linux on any new device I purchased.