Socket
Socket
Sign inDemoInstall

clipboard-sys

Package Overview
Dependencies
20
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    clipboard-sys

Cross platform node system clipboard work with text, image, files


Version published
Weekly downloads
217
increased by76.42%
Maintainers
1
Install size
372 kB
Created
Weekly downloads
 

Readme

Source

clipboard-sys

Tested Released Supported node LTS versions

Access the system clipboard

  • copy/paste text
  • copy/paste image
  • copy/paste files

Cross-platform!

Supports:

  • Windows
  • Linux (xclip supporting systems) should be installed xclip (sudo apt-get install xclip)
  • MacOS

Install

npm install clipboard-sys

Usage

import { clipboard } from './index';
import fs from 'fs';

async function readWriteText() {
  await clipboard.writeText('some text');
  console.log('text from clipboard:', await clipboard.readText());
}
readWriteText();

async function readWriteImage() {
  await clipboard.writeImage('./source.png');
  await clipboard.readImage('./destination.png');

  await clipboard.writeImage(fs.readFileSync('./source.png')); //buffer
  return await clipboard.readImage(); //buffer
}
readWriteImage();

async function copyFiles() {
  await clipboard.writeFiles('./source1.txt', './source2.png');
  console.log(await clipboard.readFiles());
}
copyFiles();

async function pasteFiles() {
  await clipboard.pasteFiles('Copy', './destinationFolder', './source1.png', './source2.png');
  await clipboard.pasteFiles('Cut', './destinationFolder', './source1.png', './source2.png');
}
pasteFiles();

API

export interface SysClipboard {
  readText(): Promise<string>;
  writeText(text: string): Promise<void>;
  readImage(file?: string): Promise<Buffer>;
  writeImage(file: string | Buffer): Promise<void>;
  readFiles(): Promise<Array<string>>;
  pasteFiles(action: 'Copy' | 'Cut', destinationFolder: string, ...files: Array<string>): Promise<void>;
  writeFiles(...files: Array<string>): Promise<boolean>;
}
Contribution

Opened for contribution https://github.com/udarrr/clipboard-sys

Keywords

FAQs

Last updated on 01 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc