Files
glassMxrph/quickshell/services/EmojiService.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

56 lines
1.8 KiB
QML

pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
// Emoji for the launcher's emoji mode, from assets/emoji.tsv (scripts/emoji-data).
// The list is read the first time emoji mode opens and kept for the session.
Singleton {
id: root
// Unicode order: {emoji, name, keywords} with lower-case search text.
property var entries: []
property bool loaded: false
function load() {
if (!file.path)
file.path = Qt.resolvedUrl("../assets/emoji.tsv").toString().replace("file://", "");
}
// Space-separated terms, all required. Name matches come before keyword
// matches; Unicode order is kept within each.
function filter(query) {
const terms = query.toLowerCase().split(/\s+/).filter(t => t);
if (!terms.length)
return entries;
const named = [], tagged = [];
for (const e of entries) {
if (!terms.every(t => e.search.includes(t)))
continue;
(terms.every(t => e.lowerName.includes(t)) ? named : tagged).push(e);
}
return named.concat(tagged);
}
function copy(entry) {
if (!entry)
return false;
Quickshell.execDetached(["wl-copy", "--", entry.emoji]);
return true;
}
FileView {
id: file
onLoaded: {
root.entries = text().split("\n").filter(line => line).map(line => {
const [emoji, name, keywords] = line.split("\t");
const lowerName = name.toLowerCase();
return {
emoji: emoji,
name: name,
lowerName: lowerName,
search: lowerName + " " + (keywords || "")
};
});
root.loaded = true;
}
}
}