先日リリースされたUbuntu 21.
Waylandセッションになったということ
Waylandとは2008年に登場したの次世代ディスプレイサーバーです。もともとは、
WaylandはX Window Systemの正当な後継という位置づけであるため、
メジャーなLinuxディストリビューションにおいて先陣を切ったのは、
Ubuntuは2017年の17.
さて、
たとえばGNOMEの場合、
画面共有に関わるさまざまなツールが協調して取り込まれないといけなかったため、
WaylandセッションでアプリをSSH越しに転送する
まずはUbuntu 21.
$ echo $XDG_SESSION_TYPE wayland
リモート側にSSHサーバーをインストールして、
リモート$ sudo apt install openssh-server
通常であれば、-X
」
クライアント$ ssh -X リモートサーバー gedit
おそらく何も反応がないでしょう。たとえばリモート側ですでにGUIにログインしている状態なら、
試しにgeditではなくてFirefoxを起動してみるとどうでしょうか。
クライアント$ ssh -X リモートサーバー firefox
こちらは起動しましたね。実はUbuntuのWaylandセッションでは
FirefoxはWayland/
それに対してgeditは、
Waypipeのビルド
Waypipeはざっくり言うと
描画用のメモリーはSSH越しに共有できるため、
残念ながらまだDebianパッケージ化されていないため、
今回のターゲットはUbuntu 21.
まずは必要なパッケージをインストールします。
$ sudo apt install meson python3 pkg-config \ ninja-build build-essential \ liblz4-dev libgbm-dev libdrm-dev libavcodec-dev \ libva-dev libswscale-dev
前半の2行は必須のパッケージです。後半の2行は動画の再生や効率的な転送を求めるなら必要なライブラリです。とりあえずすべてインストールしておくと良いでしょう。
あとはソースコードをクローンして、~/bin
」
$ git clone [email protected]:mstoeckl/waypipe.git $ cd waypipe $ mkdir ~/bin build-waypipe $ meson --buildtype debugoptimized -Dprefix=$HOME/bin build-waypipe $ ninja -C build-waypipe install
これで~/bin/
」~/bin/
」
さらに、
$ sudo apt install libavcodec58 libavutil56 libswscale5 libva2 ffmpeg
このときインストールするパッケージは、
あとは実際にwaypipeコマンドを実行してみます。
$ ~/bin/waypipe -h Usage: waypipe [options] mode ... A proxy for Wayland protocol applications. Example: waypipe ssh user@server weston-terminal Modes: ssh [...] Wrap an ssh invocation to run waypipe on both ends of the connection, and automatically forward Wayland applications. server CMD Run remotely to invoke CMD and forward application data through a socket to a matching 'waypipe client' instance. client Run locally to create a Unix socket to which 'waypipe server' instances can connect. recon C T Reconnect a 'waypipe server' instance. Writes the new Unix socket path T to the control pipe C. bench B Given a connection bandwidth B in MB/sec, estimate the best compression level used to send data Options: -c, --compress C choose compression method: lz4[=#], zstd=[=#], none -d, --debug print debug messages -h, --help display this help and exit -n, --no-gpu disable protocols which would use GPU resources -o, --oneshot only permit one connected application -s, --socket S set the socket path to either create or connect to: server default: /tmp/waypipe-server.sock client default: /tmp/waypipe-client.sock ssh: sets the prefix for the socket path --version print waypipe version and exit --allow-tiled allow gpu buffers (DMABUFs) with format modifiers --control C server,ssh: set control pipe to reconnect server --display D server,ssh: the Wayland display name or path --drm-node R set the local render node. default: /dev/dri/renderD128 --remote-node R ssh: set the remote render node path --remote-bin R ssh: set the remote waypipe binary. default: waypipe --login-shell server: if server CMD is empty, run a login shell --threads T set thread pool size, default=hardware threads/2 --unlink-socket server: unlink the socket that waypipe connects to --video[=V] compress certain linear dmabufs only with a video codec V is list of options: sw,hw,bpf=1.2e5,h264,vp9
無事に実行できたのなら準備が整いました。
Waypipeでアプリケーションのウィンドウを転送してみる
まずは試しに先ほど起動できなかったgeditを実行してみます。Waypipeは
$ ~/bin/waypipe --remote-bin ~/bin/waypipe ssh リモートサーバー gedit
「--remote-bin ~/bin/
」

無事に起動できたようです。たとえば
さらに動画も再生可能です。試しにGoogle ChromeでYouTubeを再生してみましょう。Google ChromeはそのままだとXwaylandを利用して起動してしまいます。よって次のようにいくつかオプションを与えて起動してください。
Xを使うためにうまく動かないパターン: $ ~/bin/waypipe --remote-bin ~/bin/waypipe ssh リモートサーバー google-chrome [547884:547884:0508/210909.707057:ERROR:browser_main_loop.cc(1386)] Unable to open X display. Waylandで起動するパターン: $ ~/bin/waypipe --remote-bin ~/bin/waypipe ssh リモートサーバー google-chrome \ --enable-features=UseOzonePlatform --ozone-platform=wayland

ただし音声は転送されません。もし音声も転送したいのなら、
このようにWaypipeを使えば、