sway icon indicating copy to clipboard operation
sway copied to clipboard

sway/server: Implement wayland socket handover

Open Ferdi265 opened this issue 1 year ago • 2 comments

This PR implements the compositor side of the Wayland socket handover protocol as described in the KDE Wiki. The CLI options are chosen so that they are compatible with Kwin (and Hyprland):

Sway now accepts the CLI options --socket NAME and --wayland-fd FD, which pass the name of the Wayland display socket and the Wayland display socket fd number respectively. If given, Sway will use these instead of finding a free Wayland display socket name and creating it.

This allows for Sway to be used with a helper tool that automatically restarts the compositor on crashes, and allowing clients to reconnect after the compositor restart and survive the crash. The reconnecting clients look like new clients to Sway and perform all the same steps as a fresh Wayland client would. No additional handling is required on the side of Sway.

The helper tool finds and creates the Wayland socket and launches Sway with the new CLI options, restarting it when it exits with a non-zero exit code. Two such helper tools currently exist as far as I know:

Ferdi265 avatar Jul 19 '24 16:07 Ferdi265

Update: Labwc is unsure whether the Kwin CLI options are the right path forward. Before merging this, we should consider alternative mechanisms before multiple compositors standardize on a subpar mechanism. See this wl-restart issue.

Ferdi265 avatar Jul 22 '24 11:07 Ferdi265

I think this would be a nice feature. I've dropped my thoughts in https://github.com/Ferdi265/wl-restart/issues/2#issuecomment-2419679363, and pinged KDE folks about it.

emersion avatar Oct 17 '24 14:10 emersion