A command-line tool to dump X clipboard targets as JSON.
Project description
xclip-json
@readwithai - X - blog - machine-aided reading - 📖⚡️🖋️
xclip-json is a command-line utility for Linux that dumps all the different targets on the X clipboard into a machine-readable JSON format. This is a wrapper around xclip. It is useful for saving and restoring the entire clipboard for debugging purposes.
This tool requires xclip command-line utility, which is a required package.
You can install xclip on most Debian/Ubuntu-based systems with:
sudo apt-get install xclip
Installlation
You can install xclip-json using pipx:
pipx install xclip-json
Usage
You can run the command like so:
xclip-json
This outputs the contents of all targets and selection to the clipboards.
Here is some example output:
{
"CLIPBOARD": {
"STRING": "This is some plain text from the clipboard.",
"UTF8_STRING": "This is some plain text from the clipboard.",
"text/plain;charset=UTF-8": "This is some plain text from the clipboard.",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
}
}
You can then use tools such as jq to query the data. The following command is particularly useful for this:
xclip-json | jq .CLIPBOARD | jq 'keys'
Alternatives and prior work
While I could find no tool like xclip-json you can use xclip to manually list all targets on the clipboard like so: xclip -o -t TARGETS. You can then fetch a specific target with xclip -o -t $TARGET.
About me
I am @readwithai. I create tools for reading, research and agency sometimes using the markdown editor Obsidian.
I also create a stream of tools that are related to carrying out my work.
I write about lots of things - including tools like this - on X. My blog is more about reading and research and agency.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xclip_json-0.1.0.tar.gz.
File metadata
- Download URL: xclip_json-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f562621eb60386fecdb5cd8bf2a0075fd93e6d35cfa5c2959e75e02b682ac56
|
|
| MD5 |
8f8d43a4811b8f5036f00ca9dace777d
|
|
| BLAKE2b-256 |
48f3a9bbb81da171957ff440dd0b097db4f751ebe6a2d8340ddf403209403d80
|
File details
Details for the file xclip_json-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xclip_json-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d589708e6c04467d86421114bdf3b3a4a7e911f36392542d7f88cf9acb8d59bb
|
|
| MD5 |
257414154ad5699b794cd87452b42e8e
|
|
| BLAKE2b-256 |
42e0c00b8a5d19df667e91e49bec341a48a262b47fc67e7cf2547b3b31aa2de7
|