Files
hyprland-headless-stream-pl…/src/hhstream/capture.py
T
2026-09-28 05:01:41 +00:00

38 lines
1.0 KiB
Python

"""Capture backends: how one frame is obtained from the running compositor.
The backend is injected so tests never need a real compositor: the module option
`captureCommand` (see docs/CONTRACT.md) picks the program, and a fake command
produces frames in a unit test.
"""
from __future__ import annotations
import subprocess
from typing import Protocol
class CaptureBackend(Protocol):
def grab(self) -> bytes:
"""Return one complete encoded frame. Raise on failure."""
...
def size(self) -> tuple[int, int]:
"""Pixel size of the captured output, for the Hello."""
...
class CommandCapture:
"""Runs a helper that writes one frame to stdout (default: grim)."""
def __init__(self, argv: list[str], env: dict[str, str] | None = None,
timeout: float = 5.0) -> None:
raise NotImplementedError
def grab(self) -> bytes:
raise NotImplementedError
def size(self) -> tuple[int, int]:
raise NotImplementedError
__all__ = ["CaptureBackend", "CommandCapture", "subprocess"]