nomeaning777 / wsld

WSL Daemon - Stable X11 connection and time synchronisation for WSL2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WSLD: WSL Daemon

CI

Persist X11 connection when network changes or PC resumes from disconencted sleep/hibernation, and keep your WSL time in sync.

Formerly called x11-over-vsock; renamed to wsld as it gained extra functionality.

Implementation detail can be found here.

Build

This program is written in Rust. If you do not have Rust toolchain installed you can get it from https://rustup.rs/. Building on Windows also requires Visual C++ toolchain.

Install in WSL using cargo install --locked --git https://github.com/nbdd0121/wsld wsld and install in Windows using cargo install --locked --git https://github.com/nbdd0121/wsld wsldhost (The binary will be installed to ~/.cargo/bin/wsld and %USERPROFILE%\.cargo\bin\wsldhost.exe).

You can also download pre-built binaries from releases, which are automatically compiled using GitHub Actions.

Usage

In WSL, you will need to put config file .wsld.toml in your home directory. It should look like this:

# Leave out this section to disable X11 forwarding
[x11]
# X11 display number to listen *inside* WSL. The X server in Windows can specified as argument when running wsldhost.exe.
# Default to 0, can be omitted.
display = 0
# Whether to override existing X11 sockets. If your setup does not clean up /tmp automatically, then you probably want to set this to true.
# Default to false.
force = true

# Leave out this section to disable time synchronisation
# If you need time synchronisation, you should either run wsld with root, or give it `cap_sys_time` capability using `sudo setcap cap_sys_time+eip <PATH to wsld>`.
[time]
# Interval between syncs
# Default to 10min, can be omitted
interval = "1hr"

# Leave out this section to disable TCP port forwarding
# This feature is experimental, feedbacks and suggestions welcome.
# This feature will WSL localhost to Windows localhost, so you can connect
# servers running in Windows in WSL. This feature requires interaction with
# iptables, so you need to either run wsld as root or allow wsld to use sudo.
[tcp_forward]
# iptables command to use. nftables seem not to work so you need to have
# the legacy one. If you are not using Debian it is likely you need to change it.
iptables_cmd = "sudo iptables-legacy"
# Ports to forward
ports = [ 1234 ]

# Leave out this section to disable SSH agent forwarding
[ssh_agent]
# Default to the path below, can be omitted if unchanged
# Set `SSH_AUTH_SOCK` to the path you specified.
ssh_auth_sock = "/tmp/.wsld/ssh_auth_sock"

then run wsld and set DISPLAY=:0.

In Windows, start a X server (e.g. VcXsrv) on TCP port 6000, and execute wsldhost.exe --daemon with administrator privilege. To know why administrator privilege is needed, check out implementation detail. If your X server runs on a different port, you can add --display localhost:<port> to arguments.

To automatically start both services without manual intervention, see here.

About

WSL Daemon - Stable X11 connection and time synchronisation for WSL2

License:Apache License 2.0


Languages

Language:Rust 99.6%Language:Dockerfile 0.4%