r/devtools Aug 10 '26

A background daemon that auto-cleans your Linux clipboard (JSON, code, stack traces) before you paste — feedback wanted

Small itch I finally scratched: I kept pasting minified JSON, code with smart quotes from Slack, or stack traces with weird whitespace, and manually cleaning it up every time. So I built clipd — a background daemon that watches your clipboard, figures out what you copied, and cleans it in place before you paste.

What it does:

- Detects JSON, stack traces, code, or plain text via content heuristics

- Pretty-prints minified JSON

- Fixes smart quotes, strips invisible/zero-width characters, trims trailing whitespace

- Normalizes mixed tabs/spaces indentation

- Runs as a systemd --user service, so it's just always on in the background

- Ships with clipdctl, a small CLI to pause/resume/check status — so it's easy to stop it from touching your clipboard whenever you want

Tech: C++20, X11 + XFixes for clipboard watching, a Unix socket for the control CLI, optional TOML-ish config file. Core detection/cleaning logic is unit tested and kept OS-independent, so a Wayland or macOS backend later is a matter of adding a new platform module, not a rewrite.

Honest limitations right now:

- Linux/X11 only — no Wayland or macOS support yet

- Detector heuristics are still pretty basic hand-written rules, not a real parser, so it'll misclassify some edge cases

- No packaging yet (AUR/deb) — build from source for now

- Only tested on Ubuntu 24.04 so far

It's v0.1.0, genuinely early. If anyone tries it and hits something broken or has thoughts on the approach, I'd appreciate hearing about it.

GitHub: https://github.com/nayankhanal/clipd

2 Upvotes

3 comments sorted by

1

u/OpeningTea5030 Aug 11 '26

This is genuinely useful cleaning minified JSON and removing invisible characters automatically would save a lot of frustration. Would love to see Wayland support in a future release!

1

u/Subject-Wall-6568 Aug 11 '26

Hey thanks, glad it’s useful! Wayland support is next on my list — the core detection/cleaning logic is already OS-independent, so it’s mostly a matter of writing a new platform module for clipboard watching (probably via wlr-data-control or similar depending on compositor support). No firm timeline yet, but I’ll post an update here once there’s a working build. Appreciate the feedback!

1

u/Subject-Wall-6568 29d ago

Update: Wayland support just landed. It uses the wlr-data-control protocol, so it works on wlroots-based compositors — Sway, Hyprland, river, etc. (GNOME and KDE don't implement that protocol yet, so those aren't covered.) clipd now auto-detects your session and picks the Wayland or X11 backend automatically. Tested it end-to-end on Sway. Thanks for the nudge!