libclip
A cross-platform Nim library for reading/writing text from/to the clipboard
Wraps a native library — check OS Compatibility below for platform-specific linking notes.
Summary
| Latest Version | 0.1.0 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:26 |
Tags
Authors
- Laszlo Szathmary <jabba.laci@gmail.com>
Installation
nimble install libclip
choosenim install libclip
git clone https://github.com/jabbalaci/libclip
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| libclip | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.2.0 | No |
| winim >= | 3.9.4 | No |
Source
| Repository | https://github.com/jabbalaci/libclip |
|---|---|
| Homepage | https://github.com/jabbalaci/libclip |
| Registry Source | nimble_official |
README
libclip
A Nim clipboard library.
libclip is a cross-platform Nim library for reading text from the clipboard and writing text to the clipboard.
Installation
# install:
$ nimble install libclip
# remove:
$ nimble uninstall libclip
To install the latest development version:
# install:
$ nimble install "https://github.com/jabbalaci/libclip@#head"
# remove:
$ nimble uninstall "https://github.com/jabbalaci/libclip@#head"
Usage
After importing libclip/clipboard, you get two
functions:
# copy text to clipboard
proc setClipboardText(text: string): bool
# read text from clipboard
proc getClipboardText(): string
Example
import strformat
import libclip/clipboard
proc main() =
let text = "hello nim"
let backup = getClipboardText()
#
echo &"Original content of the clipboard: '{backup}'"
echo "---"
echo &"Writing the following text to the clipboard: '{text}'"
discard setClipboardText(text)
let content = getClipboardText()
echo &"Current content of the clipboard: '{content}'"
#
echo &"Restoring the original content of the clipboard: '{backup}'"
if setClipboardText(backup):
echo "# success"
else:
echo "# failed"
# ########################################
when isMainModule:
main()
Supported platforms
It was tested under Linux and Windows. Under Linux
you must have the command xsel (install it with your
package manager).
I also added MacOS support, but I couldn't try it.
Please send me a feedback if it works under Mac.
Under Mac you must have the programs pbcopy and
pbpaste.
I also added FreeBSD support.
You must have the program xsel. It's in the package xsel-conrad.
Links
This clipboard library was extracted from my larger NimPyKot library.