Files
glassMxrph/quickshell/launcher/CommandRegistry.qml
T
mxandClaude Opus 5.5 5a10469efe 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>
2026-10-15 15:16:14 +02:00

49 lines
1.6 KiB
QML

pragma Singleton
import QtQuick
import Quickshell
import "../core"
Singleton {
id: root
property var extensions: []
readonly property var commands: SettingsRegistry.pages.map(page => ({
id: page.command,
title: page.title,
description: page.description,
page: page.id,
available: page.available,
run: page.launcherAction ? () => ShellState[page.launcherAction]() : undefined
})).concat(builtins, extensions)
// `stay` commands keep the launcher open (they change its mode in place).
readonly property var builtins: [
{
id: "clipboard",
title: "Clipboard History",
description: "Search and copy from cliphist",
kind: "Command",
stay: true,
run: () => ShellState.openLauncher("clipboard")
}
]
// Extensions are registered by trusted QML code, never interpreted from search text.
function registerCommand(command) {
if (!command || !/^[a-z][a-z0-9-]*$/.test(command.id) || !command.title || typeof command.run !== "function" || commands.some(c => c.id === command.id))
return false;
extensions = extensions.concat([command]);
return true;
}
function unregisterCommand(id) {
extensions = extensions.filter(c => c.id !== id);
}
function execute(id) {
const command = commands.find(c => c.id === id);
if (!command)
return false;
if (command.run)
command.run();
else
ShellState.openSettings(command.page);
return true;
}
}