clipboard-event
clipboard-event provides clipboard text access and change callbacks for Python on Windows, macOS, and Linux. It uses native change notifications where available and has no runtime dependencies.
- Windows: reads and writes Unicode text through Win32 and listens for
WM_CLIPBOARDUPDATEon a message-only window. - macOS: reads and writes through
pbpasteandpbcopy, then observesNSPasteboard.changeCountwithout polling clipboard content continuously. - Linux / Wayland: reads and writes through
wl-pasteandwl-copy, then useswl-paste --watchfor event-driven change detection with zero idle CPU. - Linux / X11: reads and writes through
xclip(fallbackxsel) and polls with content hashing, since X11 has no clipboard-change notification. - If native monitoring cannot start on a supported platform, the library falls back to polling. Other platforms fail explicitly.
Installation
Once the package is published on PyPI:
pip install clipboard-event
The project requires Python 3.10 or newer.
Quick start
The module facade creates its default clipboard instance only when first used:
import clipboard_event
print(clipboard_event.read())
clipboard_event.write("Hello from Python")
subscription = clipboard_event.on_change(
lambda value: print(f"Clipboard changed: {value!r}"),
emit_initial=True,
)
# Later:
subscription.cancel()
clipboard_event.close()
Explicit instances
Use Clipboard when you need an independent lifecycle:
from clipboard_event import Clipboard, Subscription
clipboard = Clipboard()
def changed(value: str | None) -> None:
print(value)
subscription: Subscription = clipboard.on_change(changed)
clipboard.write("This write also triggers the callback")
subscription.cancel()
clipboard.close()
Subscription.cancel() and Clipboard.close() are idempotent. Closing a Clipboard cancels its subscriptions and releases monitor threads and native watcher resources. read() and write() remain usable after close, and a later on_change() call starts monitoring again.
Callbacks run sequentially on one Python dispatcher thread, never on a native watcher thread. One callback's exception does not stop other subscriptions. Rapid changes may coalesce, so a callback can receive only the latest value. A callback receives str for text or None when no text is available. Writes made through the library are observed like external changes.
For diagnostics, inspect the selected backend:
print(clipboard.backend_name) # "win32", "macos", "wayland", "x11", or "polling"
Support
| Platform | Python | Clipboard I/O | Change monitoring |
|---|---|---|---|
| Windows | 3.10–3.14 | Win32 Unicode text | WM_CLIPBOARDUPDATE, with polling fallback |
| macOS | 3.10–3.14 | pbcopy / pbpaste |
NSPasteboard.changeCount, with polling fallback |
| Linux / Wayland | 3.10–3.14 | wl-copy / wl-paste |
wl-paste --watch, with polling fallback |
| Linux / X11 | 3.10–3.14 | xclip (fallback xsel) |
Content-hash polling |
| Other platforms | — | Unsupported | Unsupported |
The package is pure Python. Its wheel is universal because platform integration happens at runtime through the standard library and system tools; no compiled extension is included.
Development
Create and activate a virtual environment, then install the project in editable mode:
python -m pip install -e .
python -m unittest discover -s tests -t .
python tests/native_smoke.py
Build and inspect distribution artifacts with:
python -m pip install build twine
python -m build
python -m twine check dist/*
License
MIT © 2026 Jordi Murgó.
Metadata
Release files for clipboard-event 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clipboard_event-0.2.2.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clipboard_event-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.5 kB
Release files / clipboard_event-0.2.2.tar.gz
| Download URL | clipboard_event-0.2.2.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
980f850d324f4ca3986dad3d8360b6f6b5cf5c1b915b27d089e459553d0dea32
|
|
BLAKE2b-256 checksum How to use checksums |
271100526abbf224f8aaa5875bdaf0008b26abe6a7457b94727ad756e32117a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.
Transparency logRelease files / clipboard_event-0.2.2-py3-none-any.whl
| Download URL | clipboard_event-0.2.2-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96d4e9db3b566e109a9e338ac262bd4d8ec36843301cbdd3fd011f6beabf35fb
|
|
BLAKE2b-256 checksum How to use checksums |
240838321df4c15fbcac64136b32a658a8c45b21b17d85988c5f9f5ddd1bd192
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.
Transparency log