Expand description
The reference implementation of the Zyris screen_capture capability.
zyris_caps::ScreenCapture is the contract — list_displays and screenshot. This crate is
one answer to it: HostScreenCapture captures the monitors of the machine the node runs on,
through xcap or, in a wlroots Wayland session, libwayshot. HostDisplays offers the
same enumeration without the capture, for a capability that needs the monitor layout and does
not take pictures — input, in zyris-input, is the one that does.
use zyris::{Node, NodeKind};
use zyris_caps::ScreenCaptureServer;
use zyris_screen::HostScreenCapture;
let node = Node::builder()
.name("workstation")
.kind(NodeKind::Service)
.capability(ScreenCaptureServer(HostScreenCapture::default()))
.build()
.unwrap();§Screen capture on Wayland
A Wayland compositor does not let a client read the screen, so there are two ways in and
ScreenBackend::detect picks between them at construction.
On a wlroots-based compositor — Hyprland, Sway, river, Wayfire — ScreenBackend::Wayland
talks wl_output and zwlr_screencopy directly, the same pair grim uses. This is not the
same as letting xcap do it: xcap enumerates monitors over XRandR even in a Wayland session
and then captures in Wayland’s coordinate space, and the two only agree while Xwayland can
express the compositor’s layout. Put a monitor above the origin and its y goes negative,
which X11 cannot represent, so Xwayland flattens the arrangement into a row and every captured
rectangle lands on the wrong output.
Everywhere else — GNOME, KDE, and any compositor without zwlr_screencopy — the probe fails
and ScreenBackend::Xcap takes over, reaching the screen through
org.freedesktop.portal.Screenshot. That interface has to actually be offered: a session whose
portal backend does not register it has no way to capture at all.
§Building this crate on Linux
xcap links against the display stack, so a Linux build needs development packages a headless
build of the rest of Zyris does not:
# Debian/Ubuntu
apt-get install pkg-config libclang-dev libxcb1-dev libxrandr-dev \
libdbus-1-dev libpipewire-0.3-dev libwayland-dev libegl-devWindows and macOS need nothing beyond a Rust toolchain, which is also why the docs.rs build is pinned to a Windows target: the doc builder runs Linux and has none of the packages above.
Re-exports§
Structs§
- Host
Displays - The monitor layout of this machine, for a capability that needs it but does not capture.
- Host
Screen Capture ScreenCapturefor the machine the node runs on.
Enums§
- Screen
Backend - Which platform API the capture goes through.