| Crates.io | clipawl |
| lib.rs | clipawl |
| version | 0.2.1 |
| created_at | 2025-12-21 16:53:19.923197+00 |
| updated_at | 2025-12-21 16:53:19.923197+00 |
| description | Clipboard API for Rust: Web (wasm), Android, and Linux (Wayland + X11) with a portable async API |
| homepage | |
| repository | https://github.com/mlm-games/clipawl |
| max_upload_size | |
| id | 1998283 |
| size | 58,813 |
A minimal, effective clipboard crate for Rust with a portable async API.
Supported platforms:
navigator.clipboarduse clipawl::{Clipboard, Error};
#[tokio::main]
async fn main() -> Result<(), Error> {
let mut clipboard = Clipboard::new()?;
// Write
clipboard.set_text("Hello from clipawl!").await?;
// Read
let text = clipboard.get_text().await?;
println!("Clipboard: {}", text);
Ok(())
}
ClipboardManager via JNIgetPrimaryClip() may return null if app lacks input focus or isn't the default IMEndk-context to be initialized (handled by most Android frameworks)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:
Clipboard instance alive longerclipman, wl-clipboard)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).
use clipawl::{Clipboard, ClipboardOptions, LinuxBackend, LinuxSelection};
let opts = ClipboardOptions {
linux: LinuxOptions {
selection: LinuxSelection::Primary, // Use PRIMARY selection (middle-click paste)
backend: LinuxBackend::X11, // Force X11 backend
},
};
let clipboard = Clipboard::new_with_options(opts)?;
linux-wayland (default) — Enable Wayland backendlinux-x11 (default) — Enable X11 backendDisable defaults to reduce dependencies:
clipawl = { version = "0.1", default-features = false, features = ["linux-x11"] }
Licensed under either of:
at your option.