{"id":16905694,"url":"https://github.com/yalter/wl-clipboard-rs","last_synced_at":"2025-10-18T22:46:55.113Z","repository":{"id":39613718,"uuid":"167535873","full_name":"YaLTeR/wl-clipboard-rs","owner":"YaLTeR","description":"A safe Rust crate for working with the Wayland clipboard.","archived":false,"fork":false,"pushed_at":"2025-03-24T09:33:39.000Z","size":122984,"stargazers_count":298,"open_issues_count":11,"forks_count":17,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-04T19:00:38.889Z","etag":null,"topics":["clipboard","rust","wayland"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YaLTeR.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-25T11:18:15.000Z","updated_at":"2025-04-02T10:54:15.000Z","dependencies_parsed_at":"2024-06-19T01:32:20.962Z","dependency_job_id":"f7fec626-4b1d-43ec-8b39-58a0abbd7b9d","html_url":"https://github.com/YaLTeR/wl-clipboard-rs","commit_stats":{"total_commits":162,"total_committers":11,"mean_commits":"14.727272727272727","dds":"0.11111111111111116","last_synced_commit":"1901c52b61e4e0226ecc1ed5e0d2e6b365237cd8"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YaLTeR%2Fwl-clipboard-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YaLTeR%2Fwl-clipboard-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YaLTeR%2Fwl-clipboard-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YaLTeR%2Fwl-clipboard-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YaLTeR","download_url":"https://codeload.github.com/YaLTeR/wl-clipboard-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487668,"owners_count":21112191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clipboard","rust","wayland"],"created_at":"2024-10-13T18:39:18.786Z","updated_at":"2025-10-18T22:46:55.045Z","avatar_url":"https://github.com/YaLTeR.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wl-clipboard-rs\n\n[![crates.io](https://img.shields.io/crates/v/wl-clipboard-rs.svg)](https://crates.io/crates/wl-clipboard-rs)\n[![Build Status](https://github.com/YaLTeR/wl-clipboard-rs/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/YaLTeR/wl-clipboard-rs/actions/workflows/ci.yml?query=branch%3Amaster)\n[![Documentation](https://docs.rs/wl-clipboard-rs/badge.svg)](https://docs.rs/wl-clipboard-rs)\n\n[Documentation (master)](https://yalter.github.io/wl-clipboard-rs/wl_clipboard_rs/)\n\nA safe Rust crate for working with the Wayland clipboard.\n\nThis crate is intended to be used by terminal applications, clipboard managers and other\nutilities which don't spawn Wayland surfaces (windows). If your application has a window,\nplease use the appropriate Wayland protocols for interacting with the Wayland clipboard\n(`wl_data_device` from the core Wayland protocol, the `primary_selection` protocol for the\nprimary selection), for example via the\n[smithay-clipboard](https://crates.io/crates/smithay-clipboard) crate.\n\nThe protocol used for clipboard interaction is `ext-data-control` or `wlr-data-control`. When\nusing the regular clipboard, the compositor must support any version of either protocol. When\nusing the \"primary\" clipboard, the compositor must support any version of `ext-data-control`,\nor the second version of the `wlr-data-control` protocol.\n\nFor example applications using these features, see `wl-clipboard-rs-tools/src/bin/wl_copy.rs`\nand `wl-clipboard-rs-tools/src/bin/wl_paste.rs` which implement terminal apps similar to\n[wl-clipboard](https://github.com/bugaevc/wl-clipboard) or\n`wl-clipboard-rs-tools/src/bin/wl_clip.rs` which implements a Wayland version of `xclip`.\n\nThe Rust implementation of the Wayland client is used by default; use the `native_lib` feature\nto link to `libwayland-client.so` for communication instead. A `dlopen` feature is also\navailable for loading `libwayland-client.so` dynamically at runtime rather than linking to it.\n\nThe code of the crate itself (and the code of the example utilities) is 100% safe Rust. This\ndoesn't include the dependencies.\n\n## Examples\n\nCopying to the regular clipboard:\n```rust\nuse wl_clipboard_rs::copy::{MimeType, Options, Source};\n\nlet opts = Options::new();\nopts.copy(Source::Bytes(\"Hello world!\".to_string().into_bytes().into()), MimeType::Autodetect)?;\n```\n\nPasting plain text from the regular clipboard:\n```rust\nuse std::io::Read;\nuse wl_clipboard_rs::{paste::{get_contents, ClipboardType, Error, MimeType, Seat}};\n\nlet result = get_contents(ClipboardType::Regular, Seat::Unspecified, MimeType::Text);\nmatch result {\n    Ok((mut pipe, _)) =\u003e {\n        let mut contents = vec![];\n        pipe.read_to_end(\u0026mut contents)?;\n        println!(\"Pasted: {}\", String::from_utf8_lossy(\u0026contents));\n    }\n\n    Err(Error::NoSeats) | Err(Error::ClipboardEmpty) | Err(Error::NoMimeType) =\u003e {\n        // The clipboard is empty or doesn't contain text, nothing to worry about.\n    }\n\n    Err(err) =\u003e Err(err)?\n}\n```\n\nChecking if the \"primary\" clipboard is supported (note that this might be unnecessary depending\non your crate usage, the regular copying and pasting functions do report if the primary\nselection is unsupported when it is requested):\n\n```rust\nuse wl_clipboard_rs::utils::{is_primary_selection_supported, PrimarySelectionCheckError};\n\nmatch is_primary_selection_supported() {\n    Ok(supported) =\u003e {\n        // We have our definitive result. False means that ext/wlr-data-control is present\n        // and did not signal the primary selection support, or that only wlr-data-control\n        // version 1 is present (which does not support primary selection).\n    },\n    Err(PrimarySelectionCheckError::NoSeats) =\u003e {\n        // Impossible to give a definitive result. Primary selection may or may not be\n        // supported.\n\n        // The required protocol (ext-data-control, or wlr-data-control version 2) is there,\n        // but there are no seats. Unfortunately, at least one seat is needed to check for the\n        // primary clipboard support.\n    },\n    Err(PrimarySelectionCheckError::MissingProtocol) =\u003e {\n        // The data-control protocol (required for wl-clipboard-rs operation) is not\n        // supported by the compositor.\n    },\n    Err(_) =\u003e {\n        // Some communication error occurred.\n    }\n}\n```\n\n## Included terminal utilities\n\n- `wl-paste`: implements `wl-paste` from\n  [wl-clipboard](https://github.com/bugaevc/wl-clipboard).\n- `wl-copy`: implements `wl-copy` from [wl-clipboard](https://github.com/bugaevc/wl-clipboard).\n- `wl-clip`: a Wayland version of `xclip`.\n\nStuff that would be neat to add:\n- Utility that mimics `xsel` commandline flags.\n\nLicense: MIT/Apache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalter%2Fwl-clipboard-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyalter%2Fwl-clipboard-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalter%2Fwl-clipboard-rs/lists"}