Clipboard manager never deletes image files: removed/cleared entries stay in clipboard-images/ and keep showing up in search
System details
Intel i5-7600K, NVIDIA RTX 3060 Ti, Omarchy 4.0.4-1, Hyprland 0.56.2
What's wrong?
Removing an image entry from the clipboard manager (Super+Ctrl+V → Delete), or clearing the whole history (Shift+Delete), only rewrites ~/.local/state/omarchy/clipboard-history.json. The image file in ~/.local/state/omarchy/clipboard-images/ is never deleted. The same happens when old entries drop off the end of the 300-entry historyLimit.
So images the user deliberately deleted stay on disk with no limit. They also still appear in file search and the fuzzy finder, which is a privacy problem when a screenshot held something sensitive.
Steps
- Copy an image, for example with a screenshot to the clipboard.
- Open the clipboard manager, select the entry and press Delete (or Shift+Delete to clear all).
ls ~/.local/state/omarchy/clipboard-images/: the file is still there.
On my machine 32 orphaned images had built up while the history was empty.
Cause
In shell/plugins/clipboard/Clipboard.qml, removeDisplayIndex() and confirmClearHistory() only change the in-memory list and call saveHistory(). ClipboardHistory.addEntry() trims to the limit the same way. Nothing removes entry.path from disk.
Suggested fix
After saveHistory(), delete any file in clipboard-images/ that the history no longer references. As a local workaround I run that pruning step from a systemd .path unit watching the history JSON. It skips files under 30 seconds old, because capture.sh writes the image before the entry is added.
Related: #10769 (permissions on the same directory).
Thanks for the clear repro. #14266 ("Delete image files when clipboard entries are removed or cleared") is an open PR for exactly this, including clear-all and entries trimmed by the history limit. It'd be great if you could try it and confirm on that PR that it cleans up your orphaned images. Related: #10769 tightens file modes on the same directory.
I'm on stable (4.0.4-1) and the PR targets quattro, so I can't test it without switching branches. I'll confirm once it lands in a release. From reading the diff, the remove, clear-all, limit-eviction and startup-sweep paths cover everything I reported.
Confirmed on quattro (a6dcc31) by reading the source; nothing was run. removeDisplayIndex(), confirmClearHistory() and the trim in ClipboardHistory.addEntry() only rewrite clipboard-history.json, and no QML, script, migration or timer deletes a saved image from clipboard-images/. Only capture.sh's own temporary files are removed. Codex Medium checked the same code separately and agreed. Independence isn't guaranteed, because it can read this session.
One thing any fix has to handle: capture.sh names images by content hash, so two history entries can point at the same file. A fix must delete only paths the remaining history no longer references.
Three open pull requests fix this. They are being reviewed as their own items rather than here:
- #14266 is the oldest and closes this issue. It deletes the file on remove, clear and limit eviction, and sweeps orphans at startup.
- #14819 also lowers
historyLimitto 50 and adds a one-time migration to sweep existing orphans. - #14919 is a larger rewrite that moves history storage into a locked helper with size bounds.
Choosing between them is up to the maintainer, so this issue is waiting on that. It will close when the chosen fix merges.