-
Notifications
You must be signed in to change notification settings - Fork 4
How to: Let VcXsrv and X11 apps use Unix Domain Socket under Windows 10 (including WSL)
Note: There is no proven advantages of utilizing Unix Domain Socket over TCP loopback for VcXsrv. Let me know if you have any.
Under real Linux, a X server usually listens a Unix Domain Socket (AF_UNIX) at /tmp/.x11-unix/X#
where # is the display number. However until the end of 2017, windows does not provide any Unix Domain Socket functionalities, so as the Windows port of X-Org Server: XWin, and its fork VcXsrv. The good news is: Windows 10 now supports Unix Domain Socket, and furthermore it can be used for inter-process communication even across Win32 and WSL. That means theoretically it is possible to run GUI applications even desktop environments in WSL displaying everything on VcXsrv, a Win32 application, communicating under Unix Domain Socket. You can now try it out by downloading the latest release from this repository.
- Go to the release page.
- Download and install the latest release under C drive. Currently I did not compile for any platforms other than amd64. If you need them, please compile for yourself. PRs are welcomed.
- Run VcXsrv with the following arguments:
-nolisten tcp -listen unix
. For example:./vcxsrv.exe :0 -multiwindow -nolisten tcp -listen unix
. - Right click on the X icon in the system tray and launch
xcalc
to test whether it works.
- Remove
/tmp/.X11-unix
. Command:sudo rm -rf /tmp/.X11-unix
. - Create a symlink to
/mnt/c/tmp/.X11-unix
. Command:sudo ln -s /mnt/c/tmp/.X11-unix /tmp/X11-unix
. - Download the patch for
libxcb
. If you want to patch by yourself, check the commit. - Install the patched
libxcb
to/usr/local/lib
(or anywhere you like, as long as it can be linked). Command:sudo cp libxcb.so.1.1.0 /usr/local/lib/; sudo ln -s /usr/local/lib/libxcb.so.1.1.0 /usr/local/lib/libxcb.so.1; sudo ln -s /usr/local/lib/libxcb.so.1.1.0 /usr/local/lib/libxcb.so;
. - Refresh your ld cache. Command:
sudo ldconfig
. - Run your X client with the following environment variable:
DISPLAY=:0
. Example:DISPLAY=:0 gnome-terminal
.
Because writing a new application using Unix Domain Socket is trivial but porting an old one is not. The original code does not expect a Unix Domain Socket API under Win32. I need to revisit all these assumptions. On the other hand, the path of the Unix Domain Socket used by X11 applications is hard-coded, so I have to make sure the POSIX path works under Win32 as well. Lastly, since there are still some limitations of Unix Domain Socket across Win32 and WSL, I spent lots of time debugging and patching libxcb
.