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; } }