Files
glassMxrph/quickshell/launcher/CommandRegistry.qml
T
mxandClaude Opus 5.5 b3076a4cde Add an Emoji Picker as a launcher mode with a searchable grid
The launcher gains an emoji mode like Clipboard History: >emoji switches in
place without closing or animating, and glassmxrph emoji toggles it. Emoji
show as a grid instead of named rows; the selected or hovered emoji's name is
the section label. Search requires every term and ranks name matches before
keyword matches; Enter copies with wl-copy.

assets/emoji.tsv comes from Unicode 17 emoji-test.txt without skin-tone
variants, with keywords from the rofi emopicker list (scripts/emoji-data).
The test driver caps snapshot results, since IPC replies have a size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 23:47:14 +02:00

57 lines
1.9 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")
},
{
id: "emoji",
title: "Emoji Picker",
description: "Search and copy an emoji",
kind: "Command",
stay: true,
run: () => ShellState.openLauncher("emoji")
}
]
// 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;
}
}