arboard
БесплатноБез исполняемых скриптовНе проверенCross-platform clipboard access for text and images
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
arboard
Cross-platform clipboard library by 1Password for reading and writing text and images. Provides a unified API across macOS, Windows, and Linux (X11/Wayland).
Crate: https://crates.io/crates/arboard Docs: https://docs.rs/arboard/latest/arboard/
Key Types
Clipboard
The main entry point. Create one instance to interact with the system clipboard.
use arboard::Clipboard;
let mut clipboard = Clipboard::new()?;
Important: Clipboard::new() returns Result<Clipboard, Error> - it can fail if:
- Clipboard is not supported on the platform/environment
- Another process is holding the clipboard (rare)
ImageData
Stores raw RGBA pixel data for clipboard images.
use arboard::ImageData;
use std::borrow::Cow;
let image = ImageData {
width: 100,
height: 100,
bytes: Cow::Owned(vec![0u8; 100 * 100 * 4]), // RGBA: 4 bytes per pixel
};
Pixel Format:
- Row-major order (left-to-right, top-to-bottom)
- 4 channels per pixel: Red, Green, Blue, Alpha
- Each channel is 1 byte (0-255)
- Total bytes =
width * height * 4
Error
Non-exhaustive enum with these variants:
ContentNotAvailable- Clipboard empty or wrong formatClipboardNotSupported- Platform/environment doesn't support clipboardClipboardOccupied- Another process is using the clipboardConversionFailure- Image/text couldn't be convertedUnknown { description }- Catch-all for other errors
Usage in script-kit-gpui
The codebase uses arboard for:
Clipboard History Monitoring (
src/clipboard_history/monitor.rs)- Polls clipboard every 50-500ms
- Captures both text and images
- Uses content hashing for deduplication
Copy to Clipboard (
src/clipboard_history/clipboard.rs)- Restores entries from history
- Handles both text and image content types
Selected Text Operations (
src/selected_text.rs)- Save/restore clipboard during text replacement
- Clipboard-based paste simulation
Text Injection (
src/text_injector.rs)- Snippet expansion via clipboard + Cmd+V
- Preserves original clipboard contents
Pattern: Save and Restore
script-kit-gpui consistently uses this pattern when temporarily using the clipboard:
use arboard::Clipboard;
use anyhow::{Context, Result};
fn paste_via_clipboard(text: &str) -> Result<()> {
let mut clipboard = Clipboard::new().context("Failed to access clipboard")?;
// 1. Save original contents
let original = clipboard.get_text().ok();
// 2. Set new content
clipboard.set_text(text).context("Failed to set clipboard")?;
// 3. Perform operation (e.g., simulate Cmd+V)
simulate_paste()?;
// 4. Restore original (best effort)
if let Some(original_text) = original {
let _ = clipboard.set_text(&original_text);
}
Ok(())
}
Text Operations
Get Text
let mut clipboard = Clipboard::new()?;
match clipboard.get_text() {
Ok(text) => println!("Got: {}", text),
Err(arboard::Error::ContentNotAvailable) => println!("Empty or not text"),
Err(e) => eprintln!("Error: {}", e),
}
Set Text
let mut clipboard = Clipboard::new()?;
clipboard.set_text("Hello, world!")?;
// Also accepts String, &String, Cow<str>
clipboard.set_text(String::from("owned"))?;
Set HTML
// HTML with plain text fallback
clipboard.set_html(
"<b>Bold</b> text",
Some("Bold text"), // Alt text for apps that don't support HTML
)?;
Image Operations
Get Image
let mut clipboard = Clipboard::new()?;
match clipboard.get_image() {
Ok(image) => {
println!("{}x{} image, {} bytes",
image.width, image.height, image.bytes.len());
}
Err(arboard::Error::ContentNotAvailable) => {
println!("No image on clipboard");
}
Err(e) => eprintln!("Error: {}", e),
}
Set Image
use arboard::{Clipboard, ImageData};
use std::borrow::Cow;
let mut clipboard = Clipboard::new()?;
// Create a 2x2 red/green/blue/white test image
let pixels = vec![
255, 0, 0, 255, // Red pixel
0, 255, 0, 255, // Green pixel
0, 0, 255, 255, // Blue pixel
255, 255, 255, 255, // White pixel
];
let image = ImageData {
width: 2,
height: 2,
bytes: Cow::Owned(pixels),
};
clipboard.set_image(image)?;
Convert to Owned
Use to_owned_img() when you need to store the image beyond the clipboard's lifetime:
let image = clipboard.get_image()?;
let owned: ImageData<'static> = image.to_owned_img();
// Now safe to use after clipboard is dropped
Platform Specifics
macOS
- Uses
NSPasteboardviaobjc2 - Images stored as
NSImageobjects - Most reliable platform for clipboard operations
- Efficient change detection via
changeCount
Windows
- Uses
clipboard-wincrate - Important: Clipboard is a global object, only one thread can open it at a time
- Parallel operations may fa
Установить arboard в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл arboard?
Cross-platform clipboard access for text and images
Как установить скилл arboard?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл arboard запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic