Blame SOURCES/waypipe.1

35cf2e
.\" Generated by scdoc 1.11.2
674edb
.\" Complete documentation for this program is not available as a GNU info page
674edb
.ie \n(.g .ds Aq \(aq
674edb
.el       .ds Aq '
674edb
.nh
674edb
.ad l
674edb
.\" Begin generated content:
35cf2e
.TH "waypipe" "1" "2022-04-05"
674edb
.P
674edb
.SH NAME
674edb
.P
674edb
waypipe - A transparent proxy for Wayland applications
674edb
.P
674edb
.SH SYNOPSIS
674edb
.P
674edb
\fBwaypipe\fR [options.\&.\&.\&] \fBssh\fR [ssh options] \fIdestination\fR \fIcommand.\&.\&.\&\fR
674edb
.P
674edb
\fBwaypipe\fR [options.\&.\&.\&] \fBclient\fR
674edb
.br
674edb
\fBwaypipe\fR [options.\&.\&.\&] \fBserver\fR -- \fIcommand.\&.\&.\&\fR
674edb
.br
674edb
\fBwaypipe\fR \fBrecon\fR \fIcontrol_pipe\fR \fInew_socket_path\fR
674edb
.br
674edb
\fBwaypipe\fR \fBbench\fR \fIbandwidth\fR
674edb
.br
674edb
\fBwaypipe\fR [\fB--version\fR] [\fB-h\fR, \fB--help\fR]
674edb
.P
674edb
[options.\&.\&.\&] = [\fB-c\fR, \fB--compress\fR C] [\fB-d\fR, \fB--debug\fR] [\fB-n\fR, \fB--no-gpu\fR] [\fB-o\fR, \fB--oneshot\fR] [\fB-s\fR, \fB--socket\fR S] [\fB--allow-tiled\fR] [\fB--control\fR C] [\fB--display\fR D] [\fB--drm-node\fR R] [\fB--remote-node\fR R] [\fB--remote-bin\fR R] [\fB--login-shell\fR] [\fB--threads\fR T] [\fB--unlink-socket\fR] [\fB--video\fR[=V]]
674edb
.P
674edb
.P
674edb
.SH DESCRIPTION
674edb
.P
674edb
Waypipe is a proxy for Wayland clients, with the aim of supporting behavior
674edb
like \fBssh -X\fR.\&
674edb
.P
674edb
Prefixing an \fBssh .\&.\&.\&\fR command to become \fBwaypipe ssh .\&.\&.\&\fR will automatically
674edb
run \fBwaypipe\fR both locally and remotely, and modify the ssh command to set up
674edb
forwarding between the two instances of \fBwaypipe\fR.\& The remote instance
674edb
will act like a Wayland compositor, letting Wayland applications that are
674edb
run remotely be displayed locally.\&
674edb
.P
674edb
When run as \fBwaypipe client\fR, it will open a socket (by default at
674edb
\fI/tmp/waypipe-client.\&sock\fR) and will connect to the local Wayland compositor
674edb
and forward all Wayland applications which were linked to it over the socket
674edb
by a matching \fBwaypipe server\fR instance.\&
674edb
.P
674edb
When run as \fBwaypipe server\fR, it will run the command that follows in its
674edb
command line invocation, set up its own Wayland compositor socket, and
674edb
try to connect to its matching \fBwaypipe client\fR socket (by default
674edb
\fI/tmp/waypipe-server.\&sock\fR) and try to forward all the Wayland clients
674edb
that connect to fake compositor socket to the matching \fBwaypipe client\fR.\&
674edb
.P
674edb
The \fBwaypipe recon\fR mode is used to reconnect a \fBwaypipe server\fR instance
674edb
which has had a control pipe (option \fB--control\fR) set.\& The new socket path
674edb
should indicate a Unix socket whose connections are forwarded to the \fBwaypipe
674edb
client\fR that the \fBwaypipe server\fR was initially connected to.\&
674edb
.P
674edb
The \fBwaypipe bench\fR mode can be used to estimate, given a specific
674edb
connection \fIbandwidth\fR in MB/sec, which compression options produce the
674edb
lowest latency.\& It tests two synthetic images, one made to be roughly as
674edb
compressible as images containing text, and one made to be roughly as
674edb
compressible as images containing pictures.\&
674edb
.P
674edb
.SH OPTIONS
674edb
.P
674edb
\fB-c C, --compress C\fR
674edb
.RS 4
674edb
Select the compression method applied to data transfers.\& Options are
674edb
\fInone\fR (for high-bandwidth networks), \fIlz4\fR (intermediate), \fIzstd\fR
35cf2e
(slow connection).\& The default compression is \fInone\fR.\&† The compression
674edb
level can be chosen by appending = followed by a number.\& For example,
674edb
if \fBC\fR is \fIzstd=7\fR, waypipe will use level 7 Zstd compression.\&
674edb
.P
35cf2e
† In a future version, the default will change to \fIlz4\fR.\&
35cf2e
.P
674edb
.RE
674edb
\fB-d, --debug\fR
674edb
.RS 4
674edb
Print debug log messages.\&
674edb
.P
674edb
.RE
674edb
\fB-h, --help\fR
674edb
.RS 4
674edb
Show help message and quit.\&
674edb
.P
674edb
.RE
674edb
\fB-n, --no-gpu\fR
674edb
.RS 4
674edb
Block protocols like wayland-drm and linux-dmabuf which require access
674edb
to e.\&g.\& render nodes.\&
674edb
.P
674edb
.RE
674edb
\fB-o, --oneshot\fR
674edb
.RS 4
674edb
Only permit a single connection, and exit when it is closed.\&
674edb
.P
674edb
.RE
674edb
\fB-s S, --socket S\fR
674edb
.RS 4
674edb
Use \fBS\fR as the path for the Unix socket.\& The default socket path for
674edb
server mode is \fI/tmp/waypipe-server.\&sock\fR; for client mode, it is
674edb
\fI/tmp/waypipe-client.\&sock\fR; and in ssh mode, \fBS\fR gives the prefix used by
674edb
both the client and the server for their socket paths.\&
674edb
.P
674edb
.RE
674edb
\fB--version\fR
674edb
.RS 4
35cf2e
Briefly describe Waypipe'\&s version and the features it was built with,
35cf2e
then quit.\& Possible features: LZ4 compression support, ZSTD compression
35cf2e
support, ability to transfer DMABUFs, video compression support, VAAPI
35cf2e
hardware video de/encoding support.\&
674edb
.P
674edb
.RE
674edb
\fB--allow-tiled\fR
674edb
.RS 4
674edb
By default, waypipe filters out all advertised DMABUF formats which have
674edb
format layout modifiers, as CPU access to these formats may be very slow.\&
674edb
Setting this flag disables the filtering.\& Since tiled images often permit
674edb
faster GPU operations, most OpenGL applications will select tiling modifiers
674edb
when they are available.\&
674edb
.P
674edb
.RE
674edb
\fB--control C\fR
674edb
.RS 4
674edb
For server or ssh mode, provide the path to the "control pipe" that will
674edb
be created the the server.\& Writing (with \fBwaypipe recon C T\fR, or
35cf2e
\&'\&echo -n T > C'\&) a new socket path to this pipe will make the server
674edb
instance replace all running connections with connections to the new
674edb
Unix socket.\& The new socket should ultimately forward data to the same
674edb
waypipe client that the server was connected to before.\&
674edb
.P
674edb
.RE
674edb
\fB--display D\fR
674edb
.RS 4
674edb
For server or ssh mode, provide \fIWAYLAND_DISPLAY\fR and let waypipe configure
674edb
its Wayland display socket to have a matching path.\& (If \fBD\fR is not an
674edb
absolute path, the socket will be created in the folder given by the
674edb
environment variable \fIXDG_RUNTIME_DIR\fR.\&)
674edb
.P
674edb
.RE
674edb
\fB--drm-node R\fR
674edb
.RS 4
674edb
Specify the path \fBR\fR to the drm device that this instance of waypipe should
674edb
use and (in server mode) notify connecting applications about.\&
674edb
.P
674edb
.RE
674edb
\fB--remote-node R\fR
674edb
.RS 4
674edb
In ssh mode, specify the path \fBR\fR to the drm device that the remote instance
674edb
of waypipe (running in server mode) should use.\&
674edb
.P
674edb
.RE
674edb
\fB--remote-bin R\fR
674edb
.RS 4
674edb
In ssh mode, specify the path \fBR\fR to the waypipe binary on the remote
674edb
computer, or its name if it is available in \fIPATH\fR.\& It defaults to
674edb
\fBwaypipe\fR if this option isn’t passed.\&
674edb
.P
674edb
.RE
674edb
\fB--login-shell\fR
674edb
.RS 4
674edb
Only for server mode; if no command is being run, open a login shell.\&
674edb
.P
674edb
.RE
674edb
\fB--threads T\fR
674edb
.RS 4
674edb
Set the number of total threads (including the main thread) which a \fBwaypipe\fR
674edb
instance will create.\& These threads will be used to parallelize compression
674edb
operations.\& This flag is passed on to \fBwaypipe server\fR when given to \fBwaypipe
674edb
ssh\fR.\& The flag also controls the thread count for \fBwaypipe bench\fR.\& The default
674edb
behavior (choosable by setting \fBT\fR to \fI0\fR) is to use half as many threads
674edb
as the computer has hardware threads available.\&
674edb
.P
674edb
.RE
674edb
\fB--unlink-socket\fR
674edb
.RS 4
674edb
Only for server mode; on shutdown, unlink the Unix socket that waypipe connects to.\&
674edb
.P
674edb
.RE
674edb
\fB--video[=V]\fR
674edb
.RS 4
674edb
Compress specific DMABUF formats using a lossy video codec.\& Opaque, 10-bit, and
674edb
multiplanar formats, among others, are not supported.\& \fBV\fR is a comma separated 
674edb
list of options to control the video encoding.\& Using the \fB--video\fR flag without
674edb
setting any options is equivalent to using the default setting of:
674edb
\fB--video=sw,bpf=120000,h264\fR.\& Later options supersede earlier ones.\&
674edb
.P
674edb
\fBsw\fR
674edb
.RS 4
674edb
Use software encoding and decoding.\&
674edb
.P
674edb
.RE
674edb
\fBhw\fR
674edb
.RS 4
674edb
Use hardware (VAAPI) encoding and decoding, if available.\& This can be finicky
674edb
and may only work with specific window buffer formats and sizes.\&
674edb
.P
674edb
.RE
674edb
\fBh264\fR
674edb
.RS 4
674edb
Use H.\&264 encoded video.\&
674edb
.P
674edb
.RE
674edb
\fBvp9\fR
674edb
.RS 4
674edb
Use VP9 encoded video.\&
674edb
.P
674edb
.RE
674edb
\fBbpf=B\fR
674edb
.RS 4
674edb
Set the target bit rate of the video encoder, in units of bits per frame.\&
674edb
\fBB\fR can be written as an integer or with exponential notation; thus
674edb
\fB--video=bpf=7.\&5e5\fR is equivalent to \fB--video=bpf=750000\fR.\&
674edb
.P
674edb
.RE
674edb
.RE
674edb
\fB--hwvideo\fR
674edb
.RS 4
674edb
Deprecated option, equivalent to --video=hw .\&
674edb
.P
674edb
.RE
674edb
.SH EXAMPLE 
674edb
.P
674edb
The following \fBwaypipe ssh\fR subcommand will attempt to run \fBweston-flower\fR on
674edb
the server \fIexserv\fR, displaying the result on the local system.\&
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
	waypipe ssh user@exserv weston-flower
674edb
.fi
674edb
.RE
674edb
.P
674edb
One can obtain similar behavior by explicitly running waypipe and ssh:
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
	waypipe --socket /tmp/socket-client client  &
674edb
	ssh -R /tmp/socket-server:/tmp/socket-client user@exserv \\
674edb
		waypipe --socket /tmp/socket-server server -- weston-flower
674edb
	kill %1
674edb
.fi
674edb
.RE
674edb
.P
674edb
Waypipe may be run locally without an SSH connection by specifying matching
674edb
socket paths.\& For example:
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
	waypipe --socket /tmp/waypipe\&.sock client &
674edb
	waypipe --socket /tmp/waypipe\&.sock server weston-simple-dmabuf-egl
674edb
	kill %1
674edb
	rm /tmp/waypipe\&.sock
674edb
.fi
674edb
.RE
674edb
.P
674edb
Using transports other than SSH is a bit more complicated.\& A recipe with ncat
674edb
to connect to \fIremote\fR from computer \fIlocal\fR:
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
    $ waypipe --socket /tmp/waypipe-remote\&.sock client &
35cf2e
    $ ncat --ssl -lk 12345 --sh-exec \&'ncat -U /tmp/waypipe-remote\&.sock\&' &
674edb
    $ ssh user@remote
674edb
35cf2e
    > ncat -lkU /tmp/waypipe-local\&.sock --sh-exec \&'ncat --ssl local 12345\&' &
674edb
    > waypipe --display wayland-local \\
674edb
                --socket /tmp/waypipe-local\&.sock server -- sleep inf &
674edb
    > WAYLAND_DISPLAY=wayland-local application
674edb
.fi
674edb
.RE
674edb
.P
674edb
Given a certificate file, socat can also provide an encrypted connection
35cf2e
(remove '\&verify=0'\& to check certificates):
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
    $ waypipe --socket /tmp/waypipe-remote\&.sock client &
674edb
    $ socat openssl-listen:12345,reuseaddr,cert=certificate\&.pem,verify=0,fork \\
674edb
        unix-connect:/tmp/waypipe-remote\&.sock
674edb
    $ ssh user@remote
674edb
674edb
    > socat unix-listen:/tmp/waypipe-local\&.sock,reuseaddr,fork \\
674edb
        openssl-connect:local:12345,verify=0 &
674edb
    > waypipe --socket /tmp/waypipe-local\&.sock server -- application
674edb
.fi
674edb
.RE
674edb
.P
674edb
Many applications require specific environment variables to use Wayland instead
35cf2e
of X11.\& If ssh isn'\&t configured to support loading \fI~/.\&ssh/environment\fR,
674edb
one can use \fIenv\fR to set the needed variables each time; or run waypipe without
674edb
a command, to use the login shell environment.\&
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
	 waypipe ssh user@host env XDG_SESSION_TYPE=wayland dolphin
674edb
.fi
674edb
.RE
674edb
.P
674edb
Waypipe has support for reconnecting a \fBwaypipe client\fR and a \fBwaypipe server\fR
674edb
instance when whatever was used to transfer data between their sockets fails.\&
674edb
For this to work, waypipe must still be running on both sides of the connection.\&
674edb
As the \fBwaypipe ssh\fR wrapper will automatically close both the \fBwaypipe client\fR
674edb
and the \fBwaypipe server\fR when the connection fails, the client and server modes
674edb
must be run seprately.\& For example, to persistently forward applications running
674edb
on server \fIrserv\fR to a local Wayland compositor running on \fIlserv\fR, one would
674edb
first set up a waypipe client instance on \fIlserv\fR,
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
	waypipe -s /tmp/waypipe\&.sock client &
674edb
.fi
674edb
.RE
674edb
.P
674edb
and on server \fIrserv\fR, establish socket forwarding and run the server
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
	ssh -fN -L /tmp/waypipe-lserv\&.sock:/tmp/waypipe\&.sock user@lserv
674edb
	waypipe -s /tmp/waypipe-lserv\&.sock --control /tmp/ctrl-lserv\&.pipe \\
674edb
		--display wayland-lserv server -- sleep inf &
674edb
.fi
674edb
.RE
674edb
.P
674edb
then set \fIWAYLAND_DISPLAY=wayland-lserv\fR and run the desired applications.\&
674edb
When the ssh forwarding breaks, on \fIrserv\fR, reconnect with
674edb
.P
674edb
.nf
674edb
.RS 4
674edb
	ssh -fN -L /tmp/waypipe-lserv-2\&.sock:/tmp/waypipe\&.sock user@lserv
674edb
	waypipe recon /tmp/ctrl-lserv\&.pipe /tmp/waypipe-lserv-2\&.sock
674edb
.fi
674edb
.RE
674edb
.P
674edb
.SH ENVIRONMENT
674edb
.P
674edb
When running as a server, by default \fIWAYLAND_DISPLAY\fR will be set for the
674edb
invoked process.\&
674edb
.P
674edb
If the \fB--oneshot\fR flag is set, waypipe will instead set \fIWAYLAND_SOCKET\fR and
674edb
inherit an already connected socketpair file descriptor to the invoked (child)
674edb
process.\& Some programs open and close a Wayland connection repeatedly as part
674edb
of their initialization, and will not work correctly with this flag.\&
674edb
.P
674edb
.SH EXIT STATUS
674edb
.P
674edb
\fBwaypipe ssh\fR will exit with the exit status code from the remote command, or
674edb
with return code 1 if there has been an error.\&
674edb
.P
674edb
.SH BUGS
674edb
.P
674edb
File bug reports at: https://gitlab.\&freedesktop.\&org/mstoeckl/waypipe/
674edb
.P
674edb
Some programs (gnome-terminal, firefox, kate, among others) have special
674edb
mechanisms to ensure that only one process is running at a time.\& Starting
674edb
those programs under Waypipe while they are running under a different
674edb
Wayland compositor may silently open a window or tab in the original
674edb
instance of the program.\& Such programs may have a command line argument
674edb
to create a new instance.\&
674edb
.P
674edb
.SH SEE ALSO
674edb
.P
674edb
\fBweston\fR(1), \fBssh\fR(1), \fBsocat(1)\fR, \fBncat(1)\fR