Bring back clipboard watchers that die

Clipboard history is fed by two wl-paste --watch processes started once
when the shell loads. When one dies, nothing notices: copying still
works, the picker still opens, and the old entries are all still there,
so history just silently stops recording until the next shell reload.

Respawn them on exit instead. The one-shot timer both coalesces the case
where both watchers die together and keeps a wl-paste that cannot start
at all from spinning as fast as fork allows.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-07-28 08:19:57 -07:00
co-authored by Claude Opus 5
parent cf8102af92
commit 234ac7b3b6
2 changed files with 20 additions and 0 deletions
+15
View File
@@ -283,6 +283,7 @@ Item {
Process {
id: textWatchProc
command: ["setpriv", "--pdeathsig", "TERM", "wl-paste", "--type", "text", "--watch", root.captureScript, "text"]
onExited: watchRestartTimer.restart()
stdout: SplitParser {
onRead: function(data) { root.addClipboardJson(data) }
}
@@ -291,11 +292,25 @@ Item {
Process {
id: imageWatchProc
command: ["setpriv", "--pdeathsig", "TERM", "wl-paste", "--type", "image/png", "--watch", root.captureScript, "image/png"]
onExited: watchRestartTimer.restart()
stdout: SplitParser {
onRead: function(data) { root.addClipboardJson(data) }
}
}
// A watcher that dies takes clipboard history with it, silently: copying still
// works, the picker still opens, and the old entries are all still there, so
// nothing recorded until the next shell reload. Bring it back instead.
Timer {
id: watchRestartTimer
interval: 1000
repeat: false
onTriggered: {
if (!textWatchProc.running) textWatchProc.running = true
if (!imageWatchProc.running) imageWatchProc.running = true
}
}
PanelWindow {
id: panel
visible: root.opened