Blame SOURCES/waypipe.1

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