Add Clipboard History as a launcher mode backed by cliphist
The launcher gains a clipboard mode with the same bar, position and size: the latest five entries show at once and the rest scroll, search filters in recency order, Enter copies, Shift+Delete removes an entry. >clipboard switches in place without closing or animating; glassmxrph clipboard toggles it directly. History stays with the user's cliphist watcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
44a5aedbb2
commit
5a10469efe
15 files changed
+392
-24
No files matched your search
@@ -0,0 +1,69 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
|
||||
// Clipboard history from cliphist, for the launcher's clipboard mode. The
|
||||
// list is read only while the launcher opens; the last result stays cached so
|
||||
// switching into clipboard mode shows entries immediately.
|
||||
Singleton {
|
||||
id: root
|
||||
// Newest first: {id, text, image?, thumb?}.
|
||||
property var entries: []
|
||||
property string error: ""
|
||||
property bool loaded: false
|
||||
readonly property bool loading: lister.running
|
||||
|
||||
function refresh() {
|
||||
lister.start({
|
||||
op: "list"
|
||||
});
|
||||
}
|
||||
// Space-separated terms, all required; recency order is kept like rofi.
|
||||
function filter(query) {
|
||||
const terms = query.toLowerCase().split(/\s+/).filter(t => t);
|
||||
if (!terms.length)
|
||||
return entries;
|
||||
return entries.filter(e => {
|
||||
const text = e.text.toLowerCase();
|
||||
return terms.every(t => text.includes(t));
|
||||
});
|
||||
}
|
||||
function copy(entry) {
|
||||
return entry && actions.start({
|
||||
op: "copy",
|
||||
id: entry.id
|
||||
});
|
||||
}
|
||||
function remove(entry) {
|
||||
if (!entry)
|
||||
return false;
|
||||
// Optimistic: the row leaves at once; the helper returns the new list.
|
||||
entries = entries.filter(e => e.id !== entry.id);
|
||||
return actions.start({
|
||||
op: "delete",
|
||||
id: entry.id
|
||||
});
|
||||
}
|
||||
|
||||
ProviderJob {
|
||||
id: lister
|
||||
helper: "helpers/clipboard.py"
|
||||
onFinished: (request, result) => root.apply(result)
|
||||
}
|
||||
ProviderJob {
|
||||
id: actions
|
||||
helper: "helpers/clipboard.py"
|
||||
onFinished: (request, result) => root.apply(result)
|
||||
}
|
||||
function apply(result) {
|
||||
if (!result.ok) {
|
||||
error = result.error || "Clipboard history is unavailable";
|
||||
return;
|
||||
}
|
||||
error = "";
|
||||
if (result.entries) {
|
||||
entries = result.entries;
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,3 +17,4 @@ singleton GlassService 1.0 GlassService.qml
|
||||
singleton EasyEffectsService 1.0 EasyEffectsService.qml
|
||||
singleton PluginService 1.0 PluginService.qml
|
||||
singleton NotificationService 1.0 NotificationService.qml
|
||||
singleton ClipboardService 1.0 ClipboardService.qml
|
||||
Reference in new issue
Block a user