For whatever reason—as usual—, xclip
and other program using the X-Server stopped working on my WSL installation. I just got the following error:
Restarting WSL with wsl --shutdown
and then started it again temporarily resolved the problem, but opening a tmux
session would break it again. I tried the usual Windows shenanigans: check for updates, restart, etc. Nothing worked.
I finally found a hacky solution in a GitHub Gist written by oleksis in one of the GitHub issues of WSLg. The important part for me was this:
Init /tmp/.X11-unix is overwritten by mounts
If you still don’t see socket X0 follow these steps: issuecomment-826039096
To make it work with systemd, create /etc/tmpfiles.d/wslg.conf with following content:
# This file is part of the debianisation of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# See tmpfiles.d(5) for details
# Type Path Mode UID GID Age Argument
L+ /tmp/.X11-unix - - - - /mnt/wslg/.X11-unix