access macOS pasteboard
Project description
Pasteboard2
Pasteboard2 is a simple Python module and command line tool to get content and its types from the macOS pasteboard (clipboard). The implementation relies on PyObjC and is modeled after the Swift program pbv.
Command Line Usage
Top Level
Usage: pb2 [OPTIONS] COMMAND [ARGS]...
╭─ Options ──────────────────────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────╮
│ clear Empties the pasteboard. │
│ clip Print the content of the pasteboard if it's a string. │
│ types List the content types of the current pasteboard. │
╰────────────────────────────────────────────────────────────────────────────────────╯
Clip Subcommand
Usage: pb2 clip [OPTIONS]
Print the content of the pasteboard if it's a string.
╭─ Options ──────────────────────────────────────────────────────────────────────────╮
│ --type -t TEXT The type of content to get [default: public.utf8-plain-text] │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────╯
Test
git clone https://github.com/bwagner/pasteboard2.git
cd pasteboard2
python -m venv ~/venv/pb2
source ~/venv/pb2/bin/activate
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pytest
deactivate
rm -rf ~/venv/pb2
TODO
pbv offers reading from several pasteboards. We should, too.
Requirements
- pyobjc
- typer
- pytest (for development)
Contribute
git clone https://github.com/bwagner/pasteboard2.git
cd pasteboard2
source ~/venv/pb2/bin/activate
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pre-commit install
Alternatives
-
https://pypi.org/project/pasteboard/
https://github.com/tobywf/pasteboard
but it's no longer maintained (checked 20230710) -
https://pypi.org/project/tacky/
https://github.com/friedenberg/tacky
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pasteboard2-0.0.5.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for pasteboard2-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a91114848bc5b09de3e360922559d73cce3d747b9971f24c82d9ca54ffd80888 |
|
MD5 | ef7ed05d66b21757328e077bb5f2bcbc |
|
BLAKE2b-256 | 58185dbf23ca6cd445dddcfd154e5fbf66d474f491414641a2952f888de60143 |