rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard

It has been tested on Windows, Mac OSX, GNU/Linux, and FreeBSD

rust-clipboard

rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard.
It has been tested on Windows, Mac OSX, GNU/Linux, and FreeBSD. It is used in Mozilla Servo.

Prerequisites

On Linux you need the x11 library, install it with something like:

Example

API

The ClipboardProvider trait has the following functions:

ClipboardContext is a type alias for one of {WindowsClipboardContext, OSXClipboardContext, X11ClipboardContext, NopClipboardContext}, all of which implement ClipboardProvider. Which concrete type is chosen for ClipboardContext depends on the OS (via conditional compilation).

License

rust-clipboard is dual-licensed under MIT and Apache2.

Issues

Collection of the latest Issues

alexzanderr

alexzanderr

0

hello.

i have a minimal example.

this should copy to clipboard the string hello and then it should be pasteable with control-v everywhere.

actuall result: doesnt do anything (doesnt copy to clipboard), the clipboard is empty.

here is some neofetch: /ossssss+ WM Theme: borderless-windows -osssssso. :ssssssso. Theme: Matcha-dark-aliz [GTK2], Adwaita [GTK3 :osssssss/ osssso+++. Icons: Papirus-Dark [GTK2], Adwaita [GTK3] /ossssssss/ +ssssooo/- Terminal: tmux /ossssso+/:- -:/+osssso+- CPU: Intel i7-7700HQ (8) @ 3.800GHz +sso+:- .-/+oso: GPU: Intel HD Graphics 630 ++:. -/+/ GPU: NVIDIA GeForce GTX 1050 Mobile . / Memory: 10703MiB / 15890MiB GPU Driver: ASUSTeK Computer Inc. Device [104


specs:
- arch linux -> manjaro 22/23 Pahvo or later
- kernel 5.10
- xfce Desktop Environment

what am i missing guys? why it doesnt work?

my DE is using X11 and i saw this [merge](https://github.com/aweinstock314/rust-clipboard/pull/40) here that it was implemented for x11

jjpe

jjpe

0

This isn't an issue. It's a thank you note, because you've made it trivially simple to communicate in both directions with the clipboard. So, thank you to all the authors that have contributed to this crate!

windy1

windy1

1

Hi, so I'm not entirely sure if this is an issue with the library; I suspect it's more of a side-effect, but when acquiring a ClipboardContext on macOS from a launchd process like

my program panics with the error NSPasteboard#generalPasteboard returned null. The program works OK when I execute it directly.

I am using the following daemon descriptor:

Apologies if this isn't strictly related to this library. Any insight would be greatly appreciated!

Ninjani

Ninjani

0

Thanks for this crate, I'm using it for a terminal code snippets manager here. I'm having some issues building binaries for Linux using Travis, and the failure seems to be related to clipboard's xcb dependency. This is the error:

I've tried adding dependencies to the travis file (here) based on some other issues and pull requests from this repo, but no luck. This is the first time I'm trying something like this so maybe I've made a silly error somewhere, let me know if it's unrelated and I'll close this issue.

fschutt

fschutt

8

I've hard-forked this repository at https://github.com/fschutt/clipboard2 and changed it to return a ClipboardError enum. The problem with Box<Error> is basically that it erases all type information - the library user can only get the description, which isn't of much use except for debugging.

I've replaced all usage of Box<Error> with an error enum which is not only type-safe and more descriptive (the library use now knows why the function could fail), but also more performant (no dynamic dispatch). I'd be happy to contribute the changes back into this repo, but for now I'm using the hard fork (I'll credit your repository though, since large amounts of that repo isn't technically my code).

krzystof

krzystof

2

Hey, I have a "load selection timeout" error when doing ctx.get_contents(). I am sorry I don't get much output, but happy to provide more (I am new to Rust). I am using ubuntu 17.10, rust 1.23. I could not find anything related to that on the issues. Let me know what I can do to give you more information. Cheers

torkleyy

torkleyy

3

I've tried to build a project for Android and it tried to link to xcb. Turns out this library depends on xcb :)

Is Android support planned and if not, could we add a compile_error! if the target platform is Android?

ascclemens

ascclemens

4

Being able to read the clipboard as a vector or slice of u8s would be extremely useful to anyone who needs to work with the clipboard not just with strings.

I know this is feasible in Windows, and I think it can be done in macOS (from what I read of the current implementation), but I don't know about in X11.

Information - Updated May 13, 2022

Stars: 280
Forks: 66
Issues: 32

pancurses is a curses library for Rust that supports both Linux and Windows

by abstracting away the backend that it uses

pancurses is a curses library for Rust that supports both Linux and Windows

Native Rust library for managing Linux Control Groups (cgroups)

This crate, curently, only supports the original, V1 hierarchy

Native Rust library for managing Linux Control Groups (cgroups)

The Rust i2cdev crate seeks to provide full access to the Linux i2cdev

in the embedded-hal traits rather than

The Rust i2cdev crate seeks to provide full access to the Linux i2cdev

The Rust spidev seeks to provide full access to the Linux spidev

The following is not an exhaustive demonstration of the Spidev

The Rust spidev seeks to provide full access to the Linux spidev

a minimal Linux kernel module written in rust

A recent build of Rust (latest nightly)

a minimal Linux kernel module written in rust

Rust Linux Worker

The Service executes arbitrary Linux commands on behalf of clients

Rust Linux Worker

Direct, unsafe Rust bindings for Linux's perf_event_open system call

This crate exports unsafe Rust wrappers for Linux system calls for accessing

Direct, unsafe Rust bindings for Linux's perf_event_open system call

A safe, sane Rust interface to libseccomp on Linux

Note: This is not a high-level interface; most functions/methods in this library directly correspond to a libseccomp function

A safe, sane Rust interface to libseccomp on Linux

A transparent TCP to SOCKSv5/HTTP proxy on Linux written in Rust

Transparent TCP proxy with iptables -j REDIRECT or nft redirect to

A transparent TCP to SOCKSv5/HTTP proxy on Linux written in Rust

Linux-Device-Driver-Rust

This is a twain Repo of Linux-Device-Driver is a long time work in which I rewrite all examples in

Linux-Device-Driver-Rust
Facebook Instagram Twitter GitHub Dribbble
Privacy