12 ms·
GWSL: Run graphical Linux apps in WSL
- fb03 6y agoVcXsrv and a bashrc to set DISPLAY= automatically did it for me export DISPLAY=$(route -n | grep UG | head -n1 | awk '{print $2}'):0 and on the Windows side, start VcXsrv with the 'Disable Access Control' combo box checked. this will enable X clients from other hosts (WSL is another host, basically) to connect to the server without too much hassle. that's it.
- prasooncc 6y agoThe first line was enough for me to make it work.Microsoft supports it officially in the latest version I think.
- shadycuz 6y agoYip, been doing it this way for years. Here is guide I originally followed. https://medium.com/@pck/how-to-use-sublime-text-3-from-command-line-with-ubuntu-bash-terminal-in-windows-10-subsystems-for-aa2ad59d088c https://medium.com/@pck/how-to-use-sublime-text-3-from-comma...
- Tepix 6y ago> Disable Access Control This was terrible advice back in the 90s and still is. An attacker anywhere on the network can listen to your input devices, insert fake keypresses, view your screen, etc. Basically a total system compromise. All without log entries. The correct way to do this is to use MIT-MAGIC-COOKIE. One the client host: $ xauth -extract - $DISPLAY Then copy the output. On the host running the X server: $ xauth nmerge - then paste the output copied previously. Press enter and CTRL-D (EOF). If you then check the output of "xhost" on the client, it should only say "Access control enabled."
- ThePhysicist 6y agoVcXsrv binds to localhost by default, so unless you already have malware on your system the added risk is quite small I'd say.
- szszrk 6y agoWhat about javascript code on a harmfull website that does requests to localhost? It used to be possible to easily scan what sites are running locally, even if js code was from a public website. [0] [0] https://defuse.ca/in-browser-port-scanning.htm https://defuse.ca/in-browser-port-scanning.htm
- ThePhysicist 6y agoA JS based exploit that hijacks the X Window System Core Protocol running on your localhost to inject key presses into your X server or steal screenshots? I mean it's possible, but it seems quite far-fetched except maybe if someone specifically targets you.
- gruez 6y agoThe main impediment is that http request won't look anything like the x window requests, so the x server would likely reject it.
- presumably 6y agoThere are actually several (published and non-published) ways to exploit that type of configuration, here is one example: https://samy.pl/slipstream/ https://samy.pl/slipstream/
- gruez 6y agoIf you're talking about the general concept of using js to spoof another protocol: that exploit involves middleboxes sniffing TCP connections at the packet level, rather than at connection/stream level. It certainly won't work for connections with a TCP server. If you're talking about using that exploit to allow access to the victim's machine from the internet: that won't work because listening interface for the x11 server is localhost, not the LAN interface.
- beowulfey 6y agoThank you for posting this. I tried many times to google how to do this and saw the magic cookie explanation, but never found a good clear description of what was happening. Much appreciated!
- Tepix 6y agoGlad to help. Btw there is a typo, you need to use "nextract", it's too late to edit it now
- numpad0 6y agoInstruction unclear: on the host running the X server, I get PS C:\Users\user> _
- tracker1 6y agomaybe something like... (cmd.exe -C xauth -extract - $Display) | xauth nmerge - first part to run via windows environment, second to pipe that to the wsl environment? Actual commands probably different, but should be something you could maybe trigger from inside .bashrc file.
- mhd 6y agoDid you do this for WSL2? I had to do some firewall shenanigans before that worked for me.
- joaomoreno 6y agoWe have a guide for it in microsoft/vscode: https://github.com/microsoft/vscode/wiki/Selfhosting-on-Windows-WSL https://github.com/microsoft/vscode/wiki/Selfhosting-on-Wind...
- eknkc 6y agoAnd that is slow as hell, laggy scrolling etc. Hope the MS implementation works better.
- nickjj 6y ago> And that is slow as hell, laggy scrolling etc. It's not slow for me. Maybe you have something else running that's interfering with WSL (Defender, etc.)? I've been using the VcXsrv set up for years (in WSL 1 and now WSL 2). It runs native GUI Linux apps really well. It's how I ran Sublime Text in WSL for a long time before I eventually switched to a different editor. I even ran i3 in it for a bit but gave up on that because it didn't work well with dual monitors. It was smooth as butter tho.
- nickjj 6y agoYou'll want to make sure clipboard sharing is enabled too. This way you can share clipboard data from WSL and Windows. My VcXsrv config is public on GitHub at: https://github.com/nickjj/dotfiles/blob/master/c/Users/Nick/AppData/Roaming/Microsoft/Windows/Start%20Menu/Programs/Startup/config.xlaunch https://github.com/nickjj/dotfiles/blob/master/c/Users/Nick/... Putting it in that directory sets VcXsrc to start when Windows boots up. You would just replace "Nick" with your Windows user name and put it in that path. Then you never have to worry about starting VcXsrv ever again. Also if anyone is using both WSL 2 and WSL 1, you need to set different values for DISPLAY depending on which version you use. My .bashrc handles this at: https://github.com/nickjj/dotfiles/blob/385007837ab787a2be2e2f29577d899550d8e3f5/.bashrc#L59-L75 https://github.com/nickjj/dotfiles/blob/385007837ab787a2be2e...
- ktpsns 6y agoWeird project description. Is it an X11 Server for Windows? If so, why doesn't it say this first (but only mentions further down that the software includes some advanced X11 Server)?
- app4soft 6y agoYou mean "Is it possible to launch X11 app based on `xlib` under Windows without WSL?", right?[0] [0] https://nitter.net/app4soft/status/1337723296922677252 https://nitter.net/app4soft/status/1337723296922677252
- alexhutcheson 6y agoIt includes binaries for VcXsrv[1], which is an X11 server for Windows. This project itself seems to be glue code that helps you set up and manage VcXsrv and it's connection with your WSL instances. [1] https://sourceforge.net/projects/vcxsrv/ https://sourceforge.net/projects/vcxsrv/
- manojlds 6y agoIsn't it officially coming anyway from Microsoft - https://www.theverge.com/2020/5/19/21263377/microsoft-windows-10-linux-gui-apps-gpu-acceleration-wsl-features https://www.theverge.com/2020/5/19/21263377/microsoft-window...
- SftwreEngnr 6y agoYou really contributed a lot to this post. Congratulations.
- 2OEH8eoCRo0 6y agoThis will be a game changer if they flesh it out. Imagine Linux apps right alongside your windows apps with their own icons and everything. Windows Terminal + Visual Studio Code + WSL2 is the bee's knees.
- folkrav 6y agoUntil they allow USB passthrough (which is more or less blocked by the fact that Hyper-V itself doesn't seem to have the feature), a whole bunch of my use cases are basically barred from WSL2. Shame, cause otherwise I really, really enjoyed using it - coming from a guy who's been on Linux for 99% of his time for ~15 years at this point.
- ljm 6y agoI really hope that happens at some point, since there's so much messing around just to get a yubikey working in WSL. I eventually gave up on that.
- uponcoffee 6y agoWsl 2 is really cool, right up until you want/need to do anything with the underlying hardware. No usb passthrough, no hardware acceleration, gpu passthrough is there but it's still early stages as performance is about half of native and vendor tooling is absent, etc It's getting better all the time though - they tease usb passthrough might be doable as it's already supported with remote desktop
- rzr 6y agowhat about audio ? next task would be to support some kind of synaptic that would update windows's menu with linux apps...
- adia 6y agoUntil WSL2 gets native support for audio, you can run Windows PulseAudio yourself - there are various guides listed in the comments of this issue: https://github.com/microsoft/WSL/issues/5816 https://github.com/microsoft/WSL/issues/5816
- mook 6y agoI've been running apps via xpra instead of X forwarding, and audio works fine there. For silly reasons I'm doing it in Docker, but there's no reason to do that part if you don't need the ephemeral containers. https://github.com/mook/wsl2-xpra-generic https://github.com/mook/wsl2-xpra-generic
- kissgyorgy 6y agoAnyone have experience with this? The only thing I miss from a Linux Desktop is https://sw.kovidgoyal.net/kitty/ https://sw.kovidgoyal.net/kitty/ but it requires direct access to GPU as I understand. Anyone tried kitty with this?
- beowulfey 6y agoI actually think WSL2 may have gpu-compute now so it may work. No guarantees though
- incrudible 6y agoVcXsrv with SSH forwarding can work quite well in my experience. It also supports OpenGL so it is worth giving a shot.
- rtodea 6y agoI recently migrated to Windows from MacOS and have found the following paid apps really helpful: 1. [Pengwin](https://www.whitewaterfoundry.com/ https://www.whitewaterfoundry.com/) - a customized Debian distribution with helpful scripts for setting up a dev environment 2. [X410](https://x410.dev/ https://x410.dev/) - a customized X11 Server They made all the setup really easy. I reuse some of the scripts from Penguin in the Ubuntu distribution. One caveat for those who want to try WSL2, which is available if you subscribe to Windows Insider program, is the instability. Some times, after an update, your WSL will not start. After some restarts everything is back to normal.
- neogodless 6y agoIs the instability related to one of the above apps? I've been using WSL2 for at least six months without that issue.
- rtodea 6y agoI don't think so. I blame it on being on the Dev release channel. To be honest I thought I had to be on the latest and greatest to take benefit of WSL2.
- Jonnax 6y agoWSL2 became available outside of insider builds in version 1903 which came out May 2019. I have not experienced WSL2 a not starting issue at all and I use it every day this year. Also what benefit does Pengwin have apart from X server? I use the Ubuntu image and I've had no issues.
- rtodea 6y agoFor me it really helped to copy and paste the commands related to the X server. For instance I had a small issue with the scale of the applications. In Windows I have 250% (recommended) scaling applied. ``` export QT_SCALE_FACTOR=2.5 export GDK_SCALE=$(echo "(${QT_SCALE_FACTOR} + 0.49) / 1" | bc) #Round ```
- Ayesh 6y ago
- Tepix 6y agoDoes this work with WSL, WSL2 or both?
- nickjj 6y agoVcXsrv works with both, IMO I would just use it directly. I've been happily using it to run GUI apps in both WSL 1 for WSL 2 for quite some time now. Check this comment for more details: https://news.ycombinator.com/item?id=25455503 https://news.ycombinator.com/item?id=25455503
- ThePhysicist 6y agoI'm running X applications like the Gnome terminal on Windows via VcXsrv, works pretty flawlessly on my 4k Surface Pro by just setting the DISPLAY environment variable and tweaking GDK_DPI_SCALE.
- app4soft 6y agoMay I just ask You for try does AzPainter V2[0] works that way on your machine? [0] https://github.com/Symbian9/azpainter https://github.com/Symbian9/azpainter
- aitchnyu 6y agoWould this be less resource-hungry than Citrix remote desktop? I had to switch back and forth native Windows and Citrix and the latter stutters and generates heavy artifacts around text.
- rishav_sharan 6y agoHere is a technet thread where Microsoft's brightest (including yours truly) discuss how to do this using a vxserver. https://techcommunity.microsoft.com/t5/windows-dev-appconsult/running-wsl-gui-apps-on-windows-10/ba-p/1493242 https://techcommunity.microsoft.com/t5/windows-dev-appconsul...
- dhimes 6y agoThat's how I do it- mostly to run urxvt. Off-Topic: I'm setting up a new machine, and wondering whether I should use WSL 1 or 2 (or both?). Is there a clear path forward for these systems? WSL 1 has served me pretty well. Most of the inter-filesystem interaction amounts to using rsync to back up directories. Otherwise it's just sshing into servers. I use virtualbox for off-line development.
- rishav_sharan 6y ago> That's how I do it- mostly to run urxvt. > Off-Topic: I'm setting up a new machine, and wondering whether I should use WSL 1 or 2 (or both?). Is there a clear path forward for these systems? WSL 1 has served me pretty well. Most of the inter-filesystem interaction amounts to using rsync to back up directories. Otherwise it's just sshing into servers. I use virtualbox for off-line development. I would recommend wsl2 for sure.
- darkstarsys 6y agoWell, except for the timekeeping problem (there are workarounds but they're annoying) and the significant networking issues (no bidirectional port forwarding so "localhost:8080" doesn't work with server in WSL and DISPLAY=:0.0 doesn't work with server on Windows).
- nacs 6y agoAlso if you connect to a VPN (like your corporate VPN using Cisco Anyconnect), you lose connectivity within WSL2... WSL is nice to have and a million times better than DOS/Powershell but it's not at Linux/Mac terminal level yet.
- science404 6y agoCan run wine on windows finally?
- DannyB2 6y agoA few years ago there was an (amusing) announcement of WINE running on WSL. The link quit working a few years ago. The broken link was: https://woafre.tk/2017/02/08/wsl-wine-runs-on-it/ https://woafre.tk/2017/02/08/wsl-wine-runs-on-it/ This is the (still working) Hacker News story: https://news.ycombinator.com/item?id=13603451 https://news.ycombinator.com/item?id=13603451
- thecureforzits 6y agoBoth Windows and Mac OS run Linux apps better than Linux does now. No greater testament to the humiliating defeat of open source than this.
- Snetry 6y agoIn what way do Windows and Mac run Linux software better than Linux?
- thecureforzits 6y agoWindows lets you run Linux apps at the same speed as raw metal Linux, but with good drivers for things like video cards, wifi, etc. Windows also gives you access to a more diverse selection of its own apps so you can get your day job done. As for Macs, you get nearly the same benefits as that but now you also get access to the best hardware money can buy, from the cpu right up. I'm sure Linux will be ported to Apple Silicon eventually, but one look at the history of Linux even on x86 laptops shows how it will suck with half-finished drivers, shitty UI and terrible touchpad semantics, etc. Linux will always be a third rate OS for desktops.
- hodgesrm 6y agoYikes, do you mean Windows Subsystem for Linux? I really appreciate MS folks putting in the effort to try something new, but WSL is close to worthless. I tried it a while back and could not get basic services to work. And why would you want Windows OS around if you just want to run Linux?
- pjmlp 6y agoMac OS is the evolution of NeXTSTEP, so that is easily done anyway. Windows, well Microsoft did a big mistake of never managing the POSIX subsystem in a proper way. Linux took off thanks to GPL, BSD ongoing legal problems at the time, and Microsoft just doing the basic regarding POSIX support on Windows.
- 6y ago
- robviren 6y agoJust ran into this yesterday. What a great solution! I now have WSL2 running graphical linux apps and got a nested VM running with Mojave so I can run osx with macOS-Simple-KVM. I can finally cross compile in a way no one should.
- fortran77 6y agoOf course, you can already run X11 apps. Run a Windows-based X11 server and connect to it from the app.
- fartcannon 6y agoIt's nice that Microsoft installed a restroom. Definitely stopped people shitting in the corner. My main problem are the cameras in the stalls.
- FpUser 6y agoI had no problem running XFCE desktops under WSL and WSL2 using XRDP and standard Windows's remote desktop client. Still feature set, GUI and overall experience under VMWare feels way better to me. Also ability to test with systemd is a plus.
- uses 6y agoWhen will Windows Linux happen? I genuinely don't understand the point of Windows as it exists anymore. * Games are developed on cross platform engines. I can't remember the last game I played that was Windows-exclusive. * Business apps work in the browser or Electron, or are otherwise cross-platform. Things that aren't, could work with emulation * Developers are using unix-like operating systems, and MS has leaned hard into that. Windows is incongruent with the rest of their developer strategy. * The server ecosystem is almost entirely Linux based, apparently even on Azure * By all appearances, Windows is now a service that upsells other services, and there won't be a Windows 11 as we would traditionally think of it * The people who know what an OS is, prefer unix-like OSes by a vast margin. The people who don't, wouldn't notice the difference. * x86 looks even less like the future than it did a month ago So I don't understand what the holdup is?
- DannyB2 6y agoThe value of Windows is to run three decades of legacy Windows applications. (four decades of MS-DOS) Being able to run those still represents an actual (but declining) value. Also the value of Intel is all that legacy software. Without the legacy software, Intel could be just another ARM or RISC V competitor.
- zamadatix 6y agoIf the question is "is there something technical preventing Microsoft from pivoting to a *nix kernel instead of NT" the answer is "no, and there hasn't been for at least 20 years - if ever".
- DannyB2 6y agoMicrosoft has already pivoted before. First was change from DOS based Windows to NT Kernel based Windows. Then again to Longhorn kernel based Windows.
- quietbritishjim 6y agoThe switch from from DOS-based Windows to NT took place over many years: development started in 1989, the first release was in 1993 and the switch only really completed in 2001 when Windows XP was released, which was the first NT release targetted at consumers. That's well over a decade. Microsoft bet a huge amount of resources on NT because they could see that DOS was never going to work on in the long term, especially on servers. There's no reason for them to spend so much resources and time on a switch a *nix kernel when there's (currently) nothing like that at stake with the NT kernel. Longhorn was the codename for Vista, which just used the same NT kernel as before (with some feature improvements, just like in every new Windows release).
- mbrumlow 6y agoI tried this app. It was okay, but it did some weird things to my bashrc, so it was banshied. I found the core x server it used but was unhappy with not being able to full screen windows on the fly. So after firing out the Frankenstein build system I was able to modify the windows x server to allow alt enter to switch a window to and from full screen (no title bar over the start bar). This one change was huge. And now gui emacs works perfectly in windoes, backed by wsl. If anybody wants I can get the patch or, uh. Becausw windows and the Frankenstein build system requirements, share the binary.
- wayneftw 6y agoThis tech is pretty cool and I used to run virtual machines and WSL, but now I just keep separate computers for separate OSes and my life is so much simpler because I never have to worry if my Windows host or VM infrastructure is causing extra complexity. If something's not working, I have exactly only one OS to worry about fixing. Now, not only is my configuration and maintenance simpler but everything runs faster because all my operating systems are running on dedicated hardware. And before anyone says "it's too expensive", it's really not terribly expensive because I get refurbed machines like this [0]. If I want a laptop I get something like this [1] and it runs Linux (or Windows of course) just fine. The only expensive machine I ever buy is a Macbook, but even those I'll buy refurbished. The last Macbook Pro I bought is from mid-2015 and I got it for only $1049 (in 2017) with 6 months of AppleCare+ still attached to it, which got me a new battery for free from Apple. [0] https://www.amazon.com/HP-EliteDesk-i7-4770-3-40Ghz-Renewed/dp/B07TZKYXW6 https://www.amazon.com/HP-EliteDesk-i7-4770-3-40Ghz-Renewed/... [1] https://www.amazon.com/Acer-A515-55G-57H8-Display-i5-1035G1-Keyboard/dp/B087RSXFSG https://www.amazon.com/Acer-A515-55G-57H8-Display-i5-1035G1-...
- johnshaft1000 6y agoI use MobaXterm which works seamlessly with WSL. No need to configure anything.
- mickotron 6y agoWSL is nice but still lacking. I prefer Windows VM on Linux host. One thing I do like is the 9p "interface" between Windows host and WSL, and the improvements they made to file sharing between the two.