Repository navigation
Conversation
211d33a to
9588d24
Compare
Expand the clipboard picker beyond text and image history: - detect files, links, emails and colours, with a Ctrl+P type filter - pin, rename and edit entries; pinned entries survive retention - action panel for OCR, QR codes, colour formats and bulk deletion - retention, entry cap, disabled apps and primary-action settings - match the menu chrome through the shared tokens and FilterInput Entry timestamps and the source app come from the focused toplevel in QML, so capture.sh keeps its existing output and tests.
9588d24 to
39ff124
Compare
[Medium impact] The changes affect the local clipboard history workflow in the Omarchy shell. Do not merge until private text stays out of process arguments, edits keep their intended target, and startup pruning and backups are ordered safely. Findings
SummaryExpands clipboard history with pins, type filters, editable entries, settings, OCR, QR decoding, and an action panel.
|
| function copyText(text) { | ||
| var value = String(text || "") | ||
| if (value.length === 0) return | ||
| Quickshell.execDetached([root.copyArgScript, value]) |
There was a problem hiding this comment.
Private text enters command lines
If other local users can read process command lines, copyText exposes recognized image text and decoded QR values to them. Copying a password or setup code passes the full value as an argument to copy-arg.sh. Send the text through standard input instead.
How this was verified: Both OCR and QR results reach execDetached([root.copyArgScript, value]), which puts the full value in the helper's command line.
| } | ||
|
|
||
| function saveEdit() { | ||
| var next = ClipboardHistory.updateEntry(root.history, root.dialogIndex, { text: String(root.dialogValue || "") }) |
There was a problem hiding this comment.
saveEdit and saveRename use the array index saved when the dialog opened. Clipboard watchers keep running, and addEntry inserts new captures at the front. If a capture arrives before save, the old index points to another entry, so saving overwrites that entry's text or title. Keep the target's key and resolve its current index when saving.
| var next = ClipboardHistory.pruneHistory(parsed, root.settings, Date.now()) | ||
| root.history = next | ||
| if (next.length !== parsed.length) root.saveHistory() |
There was a problem hiding this comment.
applyHistory prunes and saves history before checking whether the user's settings have loaded. The two FileView objects load independently. If history loads first, the default limit of 500 can delete older entries even when the user set maxEntries: 0 or a larger limit. Wait until settings have loaded or failed before pruning or accepting captures.
| // wipe the whole history. The file is plain JSON, so recovery is `cp` back. | ||
| function backupHistory() { | ||
| if (root.history.length === 0) return | ||
| Quickshell.execDetached(["cp", "-f", "--", root.historyPath, root.historyPath + ".bak"]) |
There was a problem hiding this comment.
Backup can save emptied history
backupHistory starts cp without waiting, then both delete flows immediately overwrite the source file. If that write finishes before cp opens the source, the backup contains the already-deleted history, possibly []. Finish the backup successfully before saving the destructive change.
| for (var i = 0; i < removed.length; i++) { | ||
| Quickshell.execDetached(["rm", "-f", "--", removed[i]]) |
There was a problem hiding this comment.
The backup copies only the history JSON, but commitHistory then deletes every removed image file. Even when the backup succeeds, restoring it brings back image rows whose files no longer exist. Preserve the images referenced by the backup, or back them up before removing them.
| return null | ||
| } | ||
| } else if ((match = text.match(/^rgba?\(\s*([^)]+)\)$/i))) { | ||
| var parts = match[1].split(/[,\s/]+/) |
There was a problem hiding this comment.
Opaque colors become transparent
parseColor treats a valid trailing space inside rgb() or hsl() as an empty alpha value. For example, rgb(255, 0, 0 ) becomes rgba(255, 0, 0, 0), so an opaque red is previewed and copied as fully transparent. Trim the captured components before splitting, and reject empty components instead of converting them to zero.
| height: parent.height - Style.space(24) | ||
| model: root.actionItems | ||
| spacing: 2 | ||
| clip: true | ||
| boundsBehavior: Flickable.StopAtBounds |
There was a problem hiding this comment.
Selected actions leave the screen
Keyboard navigation changes actionIndex, but never moves actionList to that row. On shorter screens or with larger theme spacing, users can select hidden actions, including deletion actions, while Enter still runs them. Bind currentIndex to actionIndex and scroll the selected row into view.
| } | ||
| stderr: StdioCollector { waitForEnd: true } | ||
| onExited: function(exitCode) { | ||
| if (exitCode === 0) root.copyText(String(qrOut.text || "").trim()) |
There was a problem hiding this comment.
Decoded QR values use plain wl-copy, so the clipboard watchers record them as new text entries. QR codes can contain setup secrets such as otpauth:// values; the existing QR capture command deliberately uses --sensitive to keep those out of history. Give QR copies a sensitive copy path instead of the shared plain-text helper.
How this was verified: The QR completion handler calls copyText, whose helper omits --sensitive, while capture.sh excludes copies marked sensitive.
| if (delta < hour) value = Math.floor(delta / minute) + "m" | ||
| else if (delta < day) value = Math.floor(delta / hour) + "h" | ||
| else if (delta < week) value = Math.floor(delta / day) + "d" | ||
| else if (delta < 5 * week) value = Math.floor(delta / week) + "w" | ||
| else { | ||
| try { return new Date(stamp).toLocaleDateString() } catch (e) { return "" } |
There was a problem hiding this comment.
Time labels ignore chosen language
relativeTime writes English unit letters and plain digits directly into displayed text. It also formats older dates using the process's locale. The repository's translation guide requires catalog strings, I18n.formatNumber, and the selected I18n.formatLocale for displayed numbers and dates. Pass the needed formatters into the model so these labels follow the chosen language. This repository requirement must be satisfied before merging.
File Used: docs/i18n.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
What
Expands the built-in clipboard picker into a fuller history manager.
Ctrl+P): Text, Images, Files, Links, Emails and Colors. Multi-file copies stay one entry.Ctrl+.), rename (Ctrl+E) and inline edit content. Pinned entries sort first and are exempt from retention.Ctrl+K): paste/copy/open, copy text from image (OCR), copy text from QR code, copy colors as HEX/RGB/HSL, edit, rename, pin, delete entry, delete recent entries by time window, delete all, open settings.~/.config/omarchy/clipboard.json:retentionDays,maxEntries,primaryAction,textRecognition,disabledApps. Password managers that mark the clipboard sensitive stay excluded.ToplevelManager.activeToplevelin QML.capture.shand its output/tests are untouched.Color.menu.*includingselected-border,Border.surfaceSpec("menu", ...),Style.font.menuFamily,Style.cornerRadiusandStyle.spacing.*. Search uses the sharedFilterInput, so IME and the hidden caret behave like the Omarchy menu.Testing
bash test/shell.d/clipboard-test.sh— all existing checks, plus new model cases for pins, retention, kinds, colors, filters, OCR search, edits, time-window deletion, settings validation and removed captures, and a copy-helper check.bash test/shell.d/i18n-test.sh— passes, including the embedded-literal scan.qmllint shell/plugins/clipboard/Clipboard.qml— clean.Screenshots
Notes
shell/plugins/clipboard/copy-arg.shcopies composed text (OCR, QR, colors) throughwl-copy.manual/08-unified-clipboard-history.mdare updated; translations can follow via the sync workflow.