clipawl
A minimal, effective clipboard crate for Rust with a portable async API.
Supported platforms:
- Web (wasm32) via
navigator.clipboard - Android via JNI + ClipboardManager
- Linux via Wayland (wl-clipboard-rs) + X11 (clipboard_x11) with runtime detection
Features
- Async-first API — works naturally with web's Promise-based clipboard
- Platform detection — automatically picks Wayland or X11 on Linux
- Documented pitfalls — explicit about Linux selection ownership, web permissions, etc.
Quick Start
use ;
async
Platform Notes
Web (wasm32)
- Requires secure context (HTTPS or localhost)
- Requires user activation (click/keypress) for most browsers
- Not available in Web Workers
Android
- Uses
ClipboardManagervia JNI getPrimaryClip()may return null if app lacks input focus or isn't the default IME- Requires
ndk-contextto be initialized (handled by most Android frameworks)
Linux
Selection ownership model: On X11 and Wayland, the app that sets the clipboard
often must continue serving the data. If your app exits immediately after set_text(),
the clipboard may appear empty to other apps.
Workarounds:
- Keep the
Clipboardinstance alive longer - Use a clipboard manager (e.g.,
clipman,wl-clipboard) - Future:
set_text_persistent()(planned)
Wayland: Requires compositor support for wlr-data-control or ext-data-control
protocols. If unavailable, clipawl falls back to X11 (XWayland).
Options
use ;
let opts = ClipboardOptions ;
let clipboard = new_with_options?;
Cargo Features
linux-wayland(default) — Enable Wayland backendlinux-x11(default) — Enable X11 backend
Disable defaults to reduce dependencies:
= { = "0.1", = false, = ["linux-x11"] }
Roadmap
- v0.1: Text read/write on Web, Android, Linux
- v0.2: Linux reliability knobs (wait-for-paste, better error messages)
- v0.3: Persistent copy for CLI workflows
- v0.4: Additional formats (HTML, image)
License
Licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
at your option.