Skip to content

clipboardRead ​

clipboardRead reads the system clipboard's current text and returns a structured error if the clipboard service is unavailable or cannot be read.

SignatureclipboardRead(): Result<string?, OsError>
tyrus
import { OsError, clipboardRead } from "tyrus:os";

function readClipboard(): Result<string?, OsError> {
    return clipboardRead();
}

Returns Ok(absent) if the clipboard is empty or holds non-text content (an image or a file list). It returns Err with ERR_OS_CLIPBOARD_UNAVAILABLE if no clipboard service is reachable, such as on a headless machine, or ERR_OS_CLIPBOARD_READ_FAILED if the text cannot be read. See clipboardWrite for a related X11-specific timing caveat when reading back a value this same program just wrote.