[−][src]Module copypasta_ext::x11_bin
Invokes xclip
/xsel
to access clipboard.
This provider ensures the clipboard contents you set remain available even after your
application exists, unlike X11ClipboardContext
.
When getting or setting the clipboard, the xclip
or xsel
binary is invoked to manage the
contents. When setting the clipboard contents, these binaries internally fork and stay alive
until the clipboard content changes.
The xclip
or xsel
must be in PATH
. Alternatively the paths of either may be set at
compile time using the XCLIP_PATH
and XSEL_PATH
environment variables. If set, the
clipboard context will automatically use those.
What binary is used is deterimined at runtime on context creation based on the compile time variables and the runtime environment.
Use the provided ClipboardContext
type alias to use this clipboard context on supported
platforms, but fall back to the standard clipboard on others.
Benefits
- Keeps contents in clipboard even after your application exists.
Drawbacks
- Requires
xclip
orxsel
to be available. - Less performant than alternatives due to binary invocation.
- Set contents may not be immediately available, because they are set in an external binary.
- May have undefined behaviour if
xclip
orxsel
are modified.
Examples
use copypasta_ext::prelude::*; use copypasta_ext::x11_bin::X11BinClipboardContext; let mut ctx = X11BinClipboardContext::new().unwrap(); println!("{:?}", ctx.get_contents()); ctx.set_contents("some string".into()).unwrap();
Use ClipboardContext
alias for better platform compatability:
use copypasta_ext::prelude::*; use copypasta_ext::x11_bin::ClipboardContext; let mut ctx = ClipboardContext::new().unwrap(); println!("{:?}", ctx.get_contents()); ctx.set_contents("some string".into()).unwrap();
Use new_with_x11
to combine with X11ClipboardContext
for better performance.
use copypasta_ext::prelude::*; use copypasta_ext::x11_bin::X11BinClipboardContext; let mut ctx = X11BinClipboardContext::new_with_x11().unwrap(); println!("{:?}", ctx.get_contents()); ctx.set_contents("some string".into()).unwrap();
Structs
X11BinClipboardContext |
Enums
Error | Represents X11 binary related error. |
Type Definitions
ClipboardContext | Platform specific context. |