1. 14
  1.  

  2. 4

    Be careful: if you connect to public WiFi, turn off public access of your X session!

    MS is apparently working on a fix so that you don’t need to do this (and is also working on a custom Wayland compositor that will integrate with Windows’ native shell, so long-term you won’t even need to run a separate X server). But for now it’s a bit of a risk, because you can forget to turn it off if/when you connect to public networks. Personally I stopped using an X server with WSL after they released WSL2 (since that’s when you started needing to enable public access) and switched to running everything in the Windows Terminal (which is excellent), because I don’t quite trust myself. That being said I’m fairly comfortable with running everything in terminals instead of using GUIs so YMMV on that front; ironically, the only thing I was using X for on Windows was running urxvt, and the Windows Terminal has gotten good enough that I don’t feel the need to do that anymore.

    1. 1

      Be careful: if you connect to public WiFi, turn off public access of your X session!

      Yeah, that’s a fair point. My Windows computer is a desktop, though, so that’s not really a concern for me.

      MS is apparently working on a fix so that you don’t need to do this (and is also working on a custom Wayland compositor that will integrate with Windows’ native shell, so long-term you won’t even need to run a separate X server).

      I can only hope that’s true!

      Personally I stopped using an X server with WSL after they released WSL2 (since that’s when you started needing to enable public access) and switched to running everything in the Windows Terminal (which is excellent), because I don’t quite trust myself.

      I’ve considered this myself, but when I saw how good Emacs looked over X410 I reconsidered. Still, I have to say I’m impressed with the progress MS have made with respect to the Terminal - now all it needs is the ability to use it in dropdown mode bound to a global hotkey. :-)

      1. 2

        Ah, yeah if you’re on a desktop then it’s not much of a concern. I use a Surface Book laptop, so I was more nervous.

        I am pretty stunned at how much progress has happened on WSL2 overall. Really never expected to go back to Windows…

        I can only hope that’s true!

        It is! Here’s a blog post from two days ago where MS says that Insider builds should get access within “the next couple of months” — https://devblogs.microsoft.com/commandline/whats-new-in-the-windows-subsystem-for-linux-september-2020/#gui-apps

        1. 1

          Thanks for sharing!

          I am pretty stunned at how much progress has happened on WSL2 overall. Really never expected to go back to Windows…

          Same here!

    2. 3

      Both Xming and XvSrv will also work with basically the same procedure, except when you start them you will want to disable access control if you are using WSL2. Every X server I’ve used on Windows has somewhat blurry text. YMMV.

      Also–and this is admittedly a nitpick–can I take a moment to point out this

      export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
      

      is way more pipelining than you possibly need? You can do all this with the basic features of awk.

      export DISPLAY=$(awk '/^nameserver / {print $2; exit;}' /etc/resolv.conf 2>/dev/null):0.0
      
      1. 2

        I use XvSrv on a hidpi monitor and have had success starting Emacs (and other GUI apps using GTK widgets) with some tweaked GDK_SCALE and GDK_DPI_SCALE settings. (See https://developer.gnome.org/gtk3/stable/gtk-x11.html)

        I can’t recall, but I think I had to tell Windows to not try to scale the XvSrv application itself as well. I’ve been using this setup long enough that I can’t remember. I haven’t had blurry text or had to crank the font like @bbatsov mentions.

        1. 1

          The standard GDK settings didn’t do anything for me for some reason. I’ll probably take a closer look at this down the road, especially if I get to use more GUI apps over X.

      2. 2

        This is the second emacs article from bbatsov where I’ve thought

        is this dude looking over my shoulder, lol

        Totally second the recommendation of X410. It’s awesome.

        1. 2

          :D :D :D

          1. 1

            I know this is a tangent, but do you mind if I ask what benefit X410 offers over VcXsrv in this context (i.e., for graphical Emacs)?

            1. 1

              For me, it was how quickly I was able to get it working and how easy it was to use. Also integrates with the native desktop very well. I haven’t used VcXsrv in a long time (pre-WSL!) and don’t remember having good experiences for whatever reason. I should give it a shot again. X410 isn’t free, but price was low enough for me to try it out.

              1. 1

                I didn’t try any of the other X servers for Windows (and there are plenty of options) - I just read a few articles recommending X410 for its simplicity, performance and good support of HiDPI screens and decided to try it out. (and I also saw some articles from people complaining about VcXsrv :D ) When I saw that X410 was just 10 EUR in the MS Store, I decided not to bother to explore any other options.