philiprehberger-clipboard
Cross-platform clipboard copy and paste in one function call.
Installation
pip install philiprehberger-clipboard
Usage
from philiprehberger_clipboard import copy, paste
copy("Hello, clipboard!")
text = paste()
print(text) # Hello, clipboard!
Clearing and checking
from philiprehberger_clipboard import clear, copy, equals
copy("secret")
equals("secret") # True
equals("other") # False
clear()
equals("") # True
Detect availability
from philiprehberger_clipboard import copy, is_available
if is_available():
copy("hello")
else:
print("install xclip / xsel / wl-clipboard to enable copy")
CLI
Copy text from stdin:
echo "Hello" | python -m philiprehberger_clipboard copy
Paste clipboard contents to stdout:
python -m philiprehberger_clipboard paste
Or use the installed script:
echo "Hello" | clipboard copy
clipboard paste
API
| Function | Description |
|---|---|
copy(text: str) -> None |
Copy a string to the system clipboard |
paste() -> str |
Read a string from the system clipboard |
is_available() -> bool |
Return True if a clipboard backend is detected on the current platform |
clear() -> None |
Clear the clipboard (equivalent to copy("")) |
equals(text: str) -> bool |
Return True if the clipboard contains exactly text; non-destructive, returns False when backend is unavailable |
ClipboardError |
Raised when clipboard tool is unavailable or operation fails |
Platform support
| Platform | Copy | Paste |
|---|---|---|
| Windows | clip.exe |
PowerShell Get-Clipboard |
| macOS | pbcopy |
pbpaste |
| Linux (X11) | xclip or xsel |
xclip or xsel |
| Linux (Wayland) | wl-copy |
wl-paste |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Release files for philiprehberger-clipboard 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| philiprehberger_clipboard-0.3.0.tar.gz | 182.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| philiprehberger_clipboard-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 188.3 kB
Release files / philiprehberger_clipboard-0.3.0.tar.gz
| Download URL | philiprehberger_clipboard-0.3.0.tar.gz |
|---|---|
| Size | 182.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e3ac545f8ce7c9bd9143205a20b382cfb61a26025f4f875cbfc76259ad1256c
|
|
BLAKE2b-256 checksum How to use checksums |
d6df9714a19803b0bafc74a279af02fc2f7cf39962bb30ba6db241802ff4d62d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / philiprehberger_clipboard-0.3.0-py3-none-any.whl
| Download URL | philiprehberger_clipboard-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b323ede95238090025be6543b3e63524ed3e3f17c25454be844e3275bc00f360
|
|
BLAKE2b-256 checksum How to use checksums |
1a59e4133e9dcaebbce9ea859c44c12079dc5132b267dd7e9e739c9ea54ac132
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|