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>
This commit is contained in:
1 parent
29dd64572a
commit
b3076a4cde
13 files changed
+2220
-29
No files matched your search
@@ -155,3 +155,12 @@ and snaps the height instead of animating it. `ClipboardService` reads the user'
|
|||||||
history through `helpers/clipboard.py` only when the launcher opens, and keeps the last list cached.
|
history through `helpers/clipboard.py` only when the launcher opens, and keeps the last list cached.
|
||||||
The helper never stores entries (the user's `wl-paste --watch cliphist store` does), decodes
|
The helper never stores entries (the user's `wl-paste --watch cliphist store` does), decodes
|
||||||
thumbnails for the newest images into the cache, and detaches `wl-copy` when copying.
|
thumbnails for the newest images into the cache, and detaches `wl-copy` when copying.
|
||||||
|
|
||||||
|
## Emoji Picker
|
||||||
|
|
||||||
|
The Emoji Picker is another launcher mode: `>emoji` switches in place like `>clipboard`, and
|
||||||
|
`glassmxrph emoji` toggles it directly. Results show as a grid of glyphs with the selected (or
|
||||||
|
hovered) emoji's name as the section label. `EmojiService` reads `assets/emoji.tsv` the first time
|
||||||
|
the mode opens; search requires every term and lists name matches before keyword matches. Enter
|
||||||
|
copies with `wl-copy`. `scripts/emoji-data` regenerates the table from Unicode's `emoji-test.txt`
|
||||||
|
(skin-tone variants omitted) plus an optional keyword list. `tests/emoji_runtime.py` covers it.
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -54,7 +54,8 @@ Singleton {
|
|||||||
}
|
}
|
||||||
property bool launcherOpen: false
|
property bool launcherOpen: false
|
||||||
property var launcherScreen: null
|
property var launcherScreen: null
|
||||||
// "apps" searches applications and commands; "clipboard" is Clipboard History.
|
// "apps" searches applications and commands; "clipboard" is Clipboard History;
|
||||||
|
// "emoji" is the Emoji Picker.
|
||||||
// Changing it on an open launcher switches in place.
|
// Changing it on an open launcher switches in place.
|
||||||
property string launcherMode: "apps"
|
property string launcherMode: "apps"
|
||||||
function activeScreen() {
|
function activeScreen() {
|
||||||
@@ -63,7 +64,7 @@ Singleton {
|
|||||||
function openLauncher(mode) {
|
function openLauncher(mode) {
|
||||||
wallpaperPickerOpen=false;
|
wallpaperPickerOpen=false;
|
||||||
dashboardOpen = false;
|
dashboardOpen = false;
|
||||||
launcherMode = mode === "clipboard" ? "clipboard" : "apps";
|
launcherMode = mode === "clipboard" || mode === "emoji" ? mode : "apps";
|
||||||
if (launcherOpen)
|
if (launcherOpen)
|
||||||
return;
|
return;
|
||||||
controlCenterOpen = false;
|
controlCenterOpen = false;
|
||||||
@@ -77,11 +78,14 @@ Singleton {
|
|||||||
else
|
else
|
||||||
openLauncher();
|
openLauncher();
|
||||||
}
|
}
|
||||||
function toggleClipboard() {
|
function toggleLauncherMode(mode) {
|
||||||
if (launcherOpen && launcherMode === "clipboard")
|
if (launcherOpen && launcherMode === mode)
|
||||||
launcherOpen = false;
|
launcherOpen = false;
|
||||||
else
|
else
|
||||||
openLauncher("clipboard");
|
openLauncher(mode);
|
||||||
|
}
|
||||||
|
function toggleClipboard() {
|
||||||
|
toggleLauncherMode("clipboard");
|
||||||
}
|
}
|
||||||
property var settingsWindow: null
|
property var settingsWindow: null
|
||||||
property bool settingsOpen: false
|
property bool settingsOpen: false
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ Singleton {
|
|||||||
kind: "Command",
|
kind: "Command",
|
||||||
stay: true,
|
stay: true,
|
||||||
run: () => ShellState.openLauncher("clipboard")
|
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.
|
// Extensions are registered by trusted QML code, never interpreted from search text.
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import "../core"
|
|||||||
// empty bar) browses every application as an icon grid; > lists commands.
|
// empty bar) browses every application as an icon grid; > lists commands.
|
||||||
// Clipboard mode (>clipboard, `glassmxrph clipboard`) lists cliphist history
|
// Clipboard mode (>clipboard, `glassmxrph clipboard`) lists cliphist history
|
||||||
// in the same bar, newest first, without closing the window to switch.
|
// in the same bar, newest first, without closing the window to switch.
|
||||||
|
// Emoji mode (>emoji, `glassmxrph emoji`) shows a searchable emoji grid the
|
||||||
|
// same way; the selected emoji's name is the section label.
|
||||||
// Runtime selects the concrete Wayland layer implementation.
|
// Runtime selects the concrete Wayland layer implementation.
|
||||||
// qmllint disable uncreatable-type
|
// qmllint disable uncreatable-type
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
@@ -39,10 +41,13 @@ PanelWindow {
|
|||||||
})
|
})
|
||||||
readonly property string query: search.text.trim()
|
readonly property string query: search.text.trim()
|
||||||
readonly property bool clipboardMode: ShellState.launcherMode === "clipboard"
|
readonly property bool clipboardMode: ShellState.launcherMode === "clipboard"
|
||||||
readonly property bool commandMode: !clipboardMode && query.startsWith(">")
|
readonly property bool emojiMode: ShellState.launcherMode === "emoji"
|
||||||
|
readonly property bool commandMode: !clipboardMode && !emojiMode && query.startsWith(">")
|
||||||
property bool browsing: false
|
property bool browsing: false
|
||||||
readonly property bool showList: clipboardMode || query !== ""
|
readonly property bool showList: clipboardMode || !emojiMode && query !== ""
|
||||||
readonly property bool showGrid: !showList && browsing
|
readonly property bool showGrid: !showList && !emojiMode && browsing
|
||||||
|
// Arrow keys move through whichever grid is showing.
|
||||||
|
readonly property int columns: emojiMode ? emojiColumns : showGrid ? gridColumns : 1
|
||||||
readonly property var allApps: ApplicationsService.launchable.map(entry => ({
|
readonly property var allApps: ApplicationsService.launchable.map(entry => ({
|
||||||
id: entry.id,
|
id: entry.id,
|
||||||
title: entry.name,
|
title: entry.name,
|
||||||
@@ -55,7 +60,13 @@ PanelWindow {
|
|||||||
description: "",
|
description: "",
|
||||||
clip: e
|
clip: e
|
||||||
})) : []
|
})) : []
|
||||||
readonly property var results: clipboardMode ? clipboardResults : showList ? (commandMode ? commands.results : apps.results) : showGrid ? allApps : []
|
readonly property var emojiResults: emojiMode && ShellState.launcherOpen ? EmojiService.filter(query).map(e => ({
|
||||||
|
id: e.emoji,
|
||||||
|
title: e.name,
|
||||||
|
description: "",
|
||||||
|
glyph: e
|
||||||
|
})) : []
|
||||||
|
readonly property var results: clipboardMode ? clipboardResults : emojiMode ? emojiResults : showList ? (commandMode ? commands.results : apps.results) : showGrid ? allApps : []
|
||||||
property int selectedIndex: 0
|
property int selectedIndex: 0
|
||||||
property string launchError: ""
|
property string launchError: ""
|
||||||
readonly property real targetWidth: Math.min(options.width, root.width - 40)
|
readonly property real targetWidth: Math.min(options.width, root.width - 40)
|
||||||
@@ -63,7 +74,11 @@ PanelWindow {
|
|||||||
readonly property real maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - (root.height * 0.22))
|
readonly property real maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - (root.height * 0.22))
|
||||||
// Clipboard mode shows the latest five rows; the rest scroll.
|
// Clipboard mode shows the latest five rows; the rest scroll.
|
||||||
readonly property real clipboardRows: 5 * 48 - 2
|
readonly property real clipboardRows: 5 * 48 - 2
|
||||||
readonly property real bodyHeight: showList ? Math.min(maxBodyHeight, Math.max(84, (clipboardMode ? Math.min(list.contentHeight, clipboardRows) : list.contentHeight) + 46 + (launchError ? 22 : 0))) : showGrid ? Math.min(maxBodyHeight, grid.contentHeight + 46) : 0
|
// Emoji mode shows six rows of the grid; the rest scroll.
|
||||||
|
readonly property int emojiCell: 52
|
||||||
|
readonly property int emojiColumns: Math.max(1, Math.floor((targetWidth - 24) / emojiCell))
|
||||||
|
readonly property real emojiRows: 6 * emojiCell
|
||||||
|
readonly property real bodyHeight: emojiMode ? Math.min(maxBodyHeight, Math.max(84, Math.min(emojiGrid.contentHeight, emojiRows) + 42)) : showList ? Math.min(maxBodyHeight, Math.max(84, (clipboardMode ? Math.min(list.contentHeight, clipboardRows) : list.contentHeight) + 46 + (launchError ? 22 : 0))) : showGrid ? Math.min(maxBodyHeight, grid.contentHeight + 46) : 0
|
||||||
// Mode switches resize without animating, so >clipboard lands in place.
|
// Mode switches resize without animating, so >clipboard lands in place.
|
||||||
property bool snapping: false
|
property bool snapping: false
|
||||||
Timer {
|
Timer {
|
||||||
@@ -76,12 +91,16 @@ PanelWindow {
|
|||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
list.contentY = 0;
|
list.contentY = 0;
|
||||||
grid.contentY = 0;
|
grid.contentY = 0;
|
||||||
|
emojiGrid.contentY = 0;
|
||||||
|
emojiGrid.hovered = "";
|
||||||
}
|
}
|
||||||
function select(offset) {
|
function select(offset) {
|
||||||
if (!results.length)
|
if (!results.length)
|
||||||
return;
|
return;
|
||||||
selectedIndex = Math.max(0, Math.min(results.length - 1, selectedIndex + offset));
|
selectedIndex = Math.max(0, Math.min(results.length - 1, selectedIndex + offset));
|
||||||
if (showGrid)
|
if (emojiMode)
|
||||||
|
emojiGrid.positionViewAtIndex(selectedIndex, GridView.Contain);
|
||||||
|
else if (showGrid)
|
||||||
grid.positionViewAtIndex(selectedIndex, GridView.Contain);
|
grid.positionViewAtIndex(selectedIndex, GridView.Contain);
|
||||||
else
|
else
|
||||||
list.positionViewAtIndex(selectedIndex, ListView.Contain);
|
list.positionViewAtIndex(selectedIndex, ListView.Contain);
|
||||||
@@ -93,6 +112,9 @@ PanelWindow {
|
|||||||
if (result.clip) {
|
if (result.clip) {
|
||||||
ClipboardService.copy(result.clip);
|
ClipboardService.copy(result.clip);
|
||||||
ShellState.launcherOpen = false;
|
ShellState.launcherOpen = false;
|
||||||
|
} else if (result.glyph) {
|
||||||
|
EmojiService.copy(result.glyph);
|
||||||
|
ShellState.launcherOpen = false;
|
||||||
} else if (result.command) {
|
} else if (result.command) {
|
||||||
const command = CommandRegistry.commands.find(c => c.id === result.id);
|
const command = CommandRegistry.commands.find(c => c.id === result.id);
|
||||||
if (!command || !command.stay)
|
if (!command || !command.stay)
|
||||||
@@ -104,7 +126,7 @@ PanelWindow {
|
|||||||
launchError = ApplicationsService.error;
|
launchError = ApplicationsService.error;
|
||||||
}
|
}
|
||||||
function toggleBrowse() {
|
function toggleBrowse() {
|
||||||
if (clipboardMode) {
|
if (clipboardMode || emojiMode) {
|
||||||
ShellState.launcherMode = "apps";
|
ShellState.launcherMode = "apps";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -125,10 +147,14 @@ PanelWindow {
|
|||||||
root.launchError = "";
|
root.launchError = "";
|
||||||
root.selectedIndex = 0;
|
root.selectedIndex = 0;
|
||||||
ClipboardService.refresh();
|
ClipboardService.refresh();
|
||||||
|
if (root.emojiMode)
|
||||||
|
EmojiService.load();
|
||||||
Qt.callLater(() => search.forceActiveFocus());
|
Qt.callLater(() => search.forceActiveFocus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onLauncherModeChanged() {
|
function onLauncherModeChanged() {
|
||||||
|
if (root.emojiMode)
|
||||||
|
EmojiService.load();
|
||||||
if (!ShellState.launcherOpen)
|
if (!ShellState.launcherOpen)
|
||||||
return;
|
return;
|
||||||
root.snapping = true;
|
root.snapping = true;
|
||||||
@@ -212,7 +238,7 @@ PanelWindow {
|
|||||||
radius: 12
|
radius: 12
|
||||||
color: root.browsing ? Theme.accent : browseArea.containsMouse ? Theme.hover : Theme.transparent
|
color: root.browsing ? Theme.accent : browseArea.containsMouse ? Theme.hover : Theme.transparent
|
||||||
Accessible.role: Accessible.Button
|
Accessible.role: Accessible.Button
|
||||||
Accessible.name: root.clipboardMode ? "Back to search" : root.browsing ? "Hide applications" : "Show all applications"
|
Accessible.name: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "Show all applications"
|
||||||
Behavior on color {
|
Behavior on color {
|
||||||
ColorAnimation {
|
ColorAnimation {
|
||||||
duration: Theme.duration / 2
|
duration: Theme.duration / 2
|
||||||
@@ -220,7 +246,7 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: root.commandMode ? ">" : !Icons.available ? (root.clipboardMode ? "⎘" : "⌕") : root.clipboardMode ? "" : ""
|
text: root.commandMode ? ">" : !Icons.available ? (root.clipboardMode ? "⎘" : root.emojiMode ? "☺" : "⌕") : root.clipboardMode ? "" : root.emojiMode ? "" : ""
|
||||||
font.family: Icons.available && !root.commandMode ? Icons.family : ""
|
font.family: Icons.available && !root.commandMode ? Icons.family : ""
|
||||||
color: root.browsing ? Theme.accentText : Theme.textSecondary
|
color: root.browsing ? Theme.accentText : Theme.textSecondary
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
@@ -234,14 +260,14 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
ToolTip.visible: browseArea.containsMouse
|
ToolTip.visible: browseArea.containsMouse
|
||||||
ToolTip.delay: 600
|
ToolTip.delay: 600
|
||||||
ToolTip.text: root.clipboardMode ? "Back to search" : root.browsing ? "Hide applications" : "All applications"
|
ToolTip.text: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "All applications"
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
id: search
|
id: search
|
||||||
objectName: "launcherSearch"
|
objectName: "launcherSearch"
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 40
|
Layout.preferredHeight: 40
|
||||||
placeholderText: root.clipboardMode ? "Clipboard History" : root.browsing ? "Search applications" : "Search :3"
|
placeholderText: root.clipboardMode ? "Clipboard History" : root.emojiMode ? "Search emoji" : root.browsing ? "Search applications" : "Search :3"
|
||||||
color: Theme.text
|
color: Theme.text
|
||||||
placeholderTextColor: Theme.textSecondary
|
placeholderTextColor: Theme.textSecondary
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
@@ -260,20 +286,20 @@ PanelWindow {
|
|||||||
ShellState.launcherOpen = false;
|
ShellState.launcherOpen = false;
|
||||||
}
|
}
|
||||||
Keys.onDownPressed: {
|
Keys.onDownPressed: {
|
||||||
if (!root.showList && !root.browsing)
|
if (!root.showList && !root.browsing && !root.emojiMode)
|
||||||
root.browsing = true;
|
root.browsing = true;
|
||||||
else
|
else
|
||||||
root.select(root.showGrid ? root.gridColumns : 1);
|
root.select(root.columns);
|
||||||
}
|
}
|
||||||
Keys.onUpPressed: root.select(root.showGrid ? -root.gridColumns : -1)
|
Keys.onUpPressed: root.select(-root.columns)
|
||||||
Keys.onRightPressed: event => {
|
Keys.onRightPressed: event => {
|
||||||
if (root.showGrid || event.modifiers & Qt.ControlModifier)
|
if (root.columns > 1 || event.modifiers & Qt.ControlModifier)
|
||||||
root.select(1);
|
root.select(1);
|
||||||
else
|
else
|
||||||
event.accepted = false;
|
event.accepted = false;
|
||||||
}
|
}
|
||||||
Keys.onLeftPressed: event => {
|
Keys.onLeftPressed: event => {
|
||||||
if (root.showGrid || event.modifiers & Qt.ControlModifier)
|
if (root.columns > 1 || event.modifiers & Qt.ControlModifier)
|
||||||
root.select(-1);
|
root.select(-1);
|
||||||
else
|
else
|
||||||
event.accepted = false;
|
event.accepted = false;
|
||||||
@@ -312,7 +338,7 @@ PanelWindow {
|
|||||||
id: section
|
id: section
|
||||||
x: 22
|
x: 22
|
||||||
y: 12
|
y: 12
|
||||||
text: root.clipboardMode ? (!root.results.length ? "" : root.query ? "Matches" : "Recent") : root.showGrid ? "Applications" : root.commandMode ? "Settings" : root.results.length ? "Top hits" : ""
|
text: root.emojiMode ? (emojiGrid.hovered || (root.results[root.selectedIndex] || {}).title || "") : root.clipboardMode ? (!root.results.length ? "" : root.query ? "Matches" : "Recent") : root.showGrid ? "Applications" : root.commandMode ? "Settings" : root.results.length ? "Top hits" : ""
|
||||||
color: Theme.textSecondary
|
color: Theme.textSecondary
|
||||||
font.pixelSize: 11
|
font.pixelSize: 11
|
||||||
font.weight: Font.DemiBold
|
font.weight: Font.DemiBold
|
||||||
@@ -479,11 +505,66 @@ PanelWindow {
|
|||||||
Accessible.onPressAction: root.activate(index)
|
Accessible.onPressAction: root.activate(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GridView {
|
||||||
|
id: emojiGrid
|
||||||
|
objectName: "launcherEmoji"
|
||||||
|
// Name of the emoji under the pointer, shown instead of the selection's.
|
||||||
|
property string hovered: ""
|
||||||
|
visible: root.emojiMode
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 32
|
||||||
|
anchors.leftMargin: 12
|
||||||
|
anchors.rightMargin: 12
|
||||||
|
anchors.bottomMargin: 10
|
||||||
|
clip: true
|
||||||
|
model: root.emojiMode ? root.results : []
|
||||||
|
cellWidth: Math.floor(width / root.emojiColumns)
|
||||||
|
cellHeight: root.emojiCell
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
delegate: Item {
|
||||||
|
id: glyph
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
readonly property bool selected: root.selectedIndex === index
|
||||||
|
width: emojiGrid.cellWidth
|
||||||
|
height: emojiGrid.cellHeight
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 3
|
||||||
|
radius: 12
|
||||||
|
color: glyph.selected ? Qt.alpha(Theme.accent, 0.35) : glyphArea.containsMouse ? Theme.hover : Theme.transparent
|
||||||
|
border.width: glyph.selected ? 1 : 0
|
||||||
|
border.color: Theme.accentVivid
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: glyph.modelData.id
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
font.pixelSize: 28
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: glyphArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onContainsMouseChanged: {
|
||||||
|
if (containsMouse)
|
||||||
|
emojiGrid.hovered = glyph.modelData.title;
|
||||||
|
else if (emojiGrid.hovered === glyph.modelData.title)
|
||||||
|
emojiGrid.hovered = "";
|
||||||
|
}
|
||||||
|
onClicked: root.activate(glyph.index)
|
||||||
|
}
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: modelData.title
|
||||||
|
Accessible.onPressAction: root.activate(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
anchors.verticalCenterOffset: 12
|
anchors.verticalCenterOffset: 12
|
||||||
visible: root.showList && root.results.length === 0
|
visible: (root.showList || root.emojiMode) && root.results.length === 0
|
||||||
text: root.clipboardMode ? (ClipboardService.error || (root.query ? "No matches" : ClipboardService.loaded ? "Clipboard history is empty" : "Loading…")) : root.commandMode ? "No matching settings" : "No results"
|
text: root.emojiMode ? (EmojiService.loaded ? "No matching emoji" : "Loading…") : root.clipboardMode ? (ClipboardService.error || (root.query ? "No matches" : ClipboardService.loaded ? "Clipboard history is empty" : "Loading…")) : root.commandMode ? "No matching settings" : "No results"
|
||||||
color: Theme.textSecondary
|
color: Theme.textSecondary
|
||||||
font.pixelSize: 13
|
font.pixelSize: 13
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ Singleton {
|
|||||||
function clipboard(): void {
|
function clipboard(): void {
|
||||||
ShellState.toggleClipboard();
|
ShellState.toggleClipboard();
|
||||||
}
|
}
|
||||||
|
// Opens the Emoji Picker, or closes it when it is showing.
|
||||||
|
function emoji(): void {
|
||||||
|
ShellState.toggleLauncherMode("emoji");
|
||||||
|
}
|
||||||
function status(): string {
|
function status(): string {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
opened: ShellState.launcherOpen,
|
opened: ShellState.launcherOpen,
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,3 +18,4 @@ singleton EasyEffectsService 1.0 EasyEffectsService.qml
|
|||||||
singleton PluginService 1.0 PluginService.qml
|
singleton PluginService 1.0 PluginService.qml
|
||||||
singleton NotificationService 1.0 NotificationService.qml
|
singleton NotificationService 1.0 NotificationService.qml
|
||||||
singleton ClipboardService 1.0 ClipboardService.qml
|
singleton ClipboardService 1.0 ClipboardService.qml
|
||||||
|
singleton EmojiService 1.0 EmojiService.qml
|
||||||
@@ -56,7 +56,9 @@ Item {
|
|||||||
query: root.search().text,
|
query: root.search().text,
|
||||||
focused: root.search().activeFocus,
|
focused: root.search().activeFocus,
|
||||||
selected: w.selectedIndex,
|
selected: w.selectedIndex,
|
||||||
results: w.results.map(r => ({
|
// IPC replies have a size limit; the emoji grid holds ~1900 results.
|
||||||
|
resultCount: w.results.length,
|
||||||
|
results: w.results.slice(0, 200).map(r => ({
|
||||||
id: r.id,
|
id: r.id,
|
||||||
title: r.title,
|
title: r.title,
|
||||||
command: !!r.command,
|
command: !!r.command,
|
||||||
|
|||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Regenerates quickshell/assets/emoji.tsv for the launcher's Emoji Picker.
|
||||||
|
Usage: scripts/emoji-data EMOJI_TEST_TXT [KEYWORDS] > quickshell/assets/emoji.tsv
|
||||||
|
EMOJI_TEST_TXT is Unicode's emoji-test.txt (nixpkgs#unicode-emoji). KEYWORDS is an
|
||||||
|
optional "<emoji> <name and keywords>" list such as the rofi emopicker's ~/.config/.emoji.
|
||||||
|
Output: emoji, name, search keywords; tab-separated, in Unicode order, skin tones omitted."""
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
LINE = re.compile(r'^([0-9A-F ]+?)\s*; fully-qualified\s*# (\S+) E[\d.]+ (.+)$')
|
||||||
|
TONES = {0x1F3FB, 0x1F3FC, 0x1F3FD, 0x1F3FE, 0x1F3FF}
|
||||||
|
|
||||||
|
extra = {}
|
||||||
|
if len(sys.argv) > 2:
|
||||||
|
for line in open(sys.argv[2], encoding='utf-8'):
|
||||||
|
emoji, _, words = line.strip().partition(' ')
|
||||||
|
extra[emoji.replace('️', '')] = words.lower().split()
|
||||||
|
|
||||||
|
subgroup = ''
|
||||||
|
for line in open(sys.argv[1], encoding='utf-8'):
|
||||||
|
if line.startswith('# subgroup:'):
|
||||||
|
subgroup = line.split(':', 1)[1].strip()
|
||||||
|
continue
|
||||||
|
match = LINE.match(line.strip())
|
||||||
|
if not match or TONES & {int(c, 16) for c in match[1].split()}:
|
||||||
|
continue
|
||||||
|
emoji, name = match[2], match[3].replace('\t', ' ')
|
||||||
|
seen = set(re.split(r'[\s:,]+', name.lower()))
|
||||||
|
words = []
|
||||||
|
for word in extra.get(emoji.replace('️', ''), []) + subgroup.split('-'):
|
||||||
|
if word not in seen:
|
||||||
|
seen.add(word)
|
||||||
|
words.append(word)
|
||||||
|
print(f'{emoji}\t{name}\t{" ".join(words)}')
|
||||||
+3
-3
@@ -31,8 +31,8 @@ case "${1:-run}" in
|
|||||||
launcher)
|
launcher)
|
||||||
exec quickshell ipc --path "$project_dir/quickshell" call launcher toggle
|
exec quickshell ipc --path "$project_dir/quickshell" call launcher toggle
|
||||||
;;
|
;;
|
||||||
clipboard)
|
clipboard|emoji)
|
||||||
exec quickshell ipc --path "$project_dir/quickshell" call launcher clipboard
|
exec quickshell ipc --path "$project_dir/quickshell" call launcher "$1"
|
||||||
;;
|
;;
|
||||||
plugin)
|
plugin)
|
||||||
# glassmxrph plugin [list|install SOURCE|remove ID|enable ID|disable ID|summon ID|toggle ID]
|
# glassmxrph plugin [list|install SOURCE|remove ID|enable ID|disable ID|summon ID|toggle ID]
|
||||||
@@ -70,5 +70,5 @@ case "${1:-run}" in
|
|||||||
settings|close|status)
|
settings|close|status)
|
||||||
exec quickshell ipc --path "$project_dir/quickshell" call shell "$1"
|
exec quickshell ipc --path "$project_dir/quickshell" call shell "$1"
|
||||||
;;
|
;;
|
||||||
*) echo 'Usage: glassmxrph [run|wallpaper|launcher|clipboard|dashboard [TAB]|plugin ACTION|controlcenter|lock|widgets|osd ACTION|notifications ACTION|settings|close|status|doctor]' >&2; exit 2 ;;
|
*) echo 'Usage: glassmxrph [run|wallpaper|launcher|clipboard|emoji|dashboard [TAB]|plugin ACTION|controlcenter|lock|widgets|osd ACTION|notifications ACTION|settings|close|status|doctor]' >&2; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Real Wayland Emoji Picker test on a private session bus.
|
||||||
|
Copying is global on Wayland, so the user's clipboard is saved and restored.
|
||||||
|
Run: dbus-run-session -- python3 tests/emoji_runtime.py [screenshot-dir]"""
|
||||||
|
import json,os,subprocess,sys,tempfile,time
|
||||||
|
from pathlib import Path
|
||||||
|
ROOT=Path(__file__).resolve().parents[1]
|
||||||
|
BASE=['quickshell','ipc','--path',str(ROOT/'quickshell'),'call']
|
||||||
|
SHOTS=Path(sys.argv[1]) if len(sys.argv)>1 else None
|
||||||
|
Key={'Return':0x01000004,'Right':0x01000014,'Down':0x01000015,'Escape':0x01000000}
|
||||||
|
def ipc(target,method,*args):
|
||||||
|
r=subprocess.run(BASE+[target,method,*map(str,args)],capture_output=True,text=True)
|
||||||
|
out=r.stdout.strip()
|
||||||
|
if r.returncode or not out:return None
|
||||||
|
try:return json.loads(out)
|
||||||
|
except ValueError:return out
|
||||||
|
def snap():return ipc('launcherTest','snapshot') or {}
|
||||||
|
def wait(check,label,timeout=10):
|
||||||
|
end=time.monotonic()+timeout
|
||||||
|
while time.monotonic()<end:
|
||||||
|
try:
|
||||||
|
if check():return
|
||||||
|
except (TypeError,KeyError,ValueError,IndexError):pass
|
||||||
|
time.sleep(.08)
|
||||||
|
raise AssertionError(label+': '+json.dumps(snap(),ensure_ascii=False)[:600])
|
||||||
|
def shot(name):
|
||||||
|
if SHOTS:
|
||||||
|
time.sleep(.5);SHOTS.mkdir(parents=True,exist_ok=True)
|
||||||
|
subprocess.run(['grim','-o',snap()['screen'],str(SHOTS/(name+'.png'))],check=False)
|
||||||
|
def pasted():return subprocess.run(['wl-paste','--no-newline'],capture_output=True,text=True,timeout=5).stdout
|
||||||
|
if 'DBUS_SESSION_BUS_ADDRESS' not in os.environ or ipc('shell','status'):raise SystemExit('Run in a private dbus-run-session with no instance from this path.')
|
||||||
|
saved=subprocess.run(['wl-paste','--no-newline'],capture_output=True,timeout=5)
|
||||||
|
log=ROOT/'.cache/emoji-runtime.log';log.parent.mkdir(exist_ok=True)
|
||||||
|
total=sum(1 for _ in open(ROOT/'quickshell/assets/emoji.tsv',encoding='utf-8'))
|
||||||
|
with tempfile.TemporaryDirectory(prefix='glassmxrph-emoji-') as tmp:
|
||||||
|
env=dict(os.environ,XDG_CONFIG_HOME=tmp+'/config',XDG_STATE_HOME=tmp+'/state',XDG_CACHE_HOME=tmp+'/cache',GLASSMXRPH_LAUNCHER_TESTING='1',QT_NO_XDG_DESKTOP_PORTAL='1')
|
||||||
|
Path(tmp,'config/glassMxrph').mkdir(parents=True)
|
||||||
|
Path(tmp,'config/glassMxrph/config.json').write_text(json.dumps({'schemaVersion':3,'dock':{'enabled':False}}))
|
||||||
|
with log.open('w') as output:
|
||||||
|
shell=subprocess.Popen([str(ROOT/'scripts/glassmxrph'),'run'],env=env,stdout=output,stderr=subprocess.STDOUT)
|
||||||
|
try:
|
||||||
|
wait(lambda:ipc('shell','status')['ready'],'ready')
|
||||||
|
ipc('launcher','open');wait(lambda:snap()['opened'] and snap()['focused'],'launcher opens')
|
||||||
|
time.sleep(.4);before=snap()
|
||||||
|
ipc('launcherTest','query','>emoji')
|
||||||
|
wait(lambda:snap()['results'][0]['id']=='emoji','emoji command listed')
|
||||||
|
ipc('launcherTest','key',Key['Return'])
|
||||||
|
wait(lambda:snap()['mode']=='emoji' and snap()['resultCount']==total,'command switches to the emoji grid')
|
||||||
|
s=snap();assert s['opened'] and s['query']=='' and s['focused'],s
|
||||||
|
assert (s['x'],s['y'],s['width'])==(before['x'],before['y'],before['width']),(before,s)
|
||||||
|
assert s['results'][0]['id']=='😀' and s['results'][0]['title']=='grinning face',s['results'][0]
|
||||||
|
time.sleep(.3);shot('1-emoji')
|
||||||
|
# Six rows visible: the body stops growing past them.
|
||||||
|
assert abs(s['height']-(60+6*52+42))<=2,s['height']
|
||||||
|
ipc('launcherTest','key',Key['Right']);ipc('launcherTest','key',Key['Down'])
|
||||||
|
cols=snap()['selected']-1;assert cols>4,snap()['selected']
|
||||||
|
ipc('launcherTest','query','heart red')
|
||||||
|
wait(lambda:snap()['results'][0]['title']=='red heart','search ranks names first')
|
||||||
|
ipc('launcherTest','query','pizza')
|
||||||
|
wait(lambda:[r['id'] for r in snap()['results']]==['🍕'],'search filters')
|
||||||
|
shot('2-search')
|
||||||
|
ipc('launcherTest','key',Key['Return'])
|
||||||
|
wait(lambda:not snap()['opened'],'copying closes')
|
||||||
|
wait(lambda:pasted()=='🍕','emoji copied')
|
||||||
|
ipc('launcherTest','query','')
|
||||||
|
ipc('launcher','emoji');wait(lambda:snap()['opened'] and snap()['mode']=='emoji','IPC opens the emoji picker')
|
||||||
|
ipc('launcherTest','query','flag germany')
|
||||||
|
wait(lambda:[r['id'] for r in snap()['results']]==['🇩🇪'],'keyword search')
|
||||||
|
ipc('launcher','emoji');wait(lambda:not snap()['opened'],'IPC toggles it closed')
|
||||||
|
ipc('launcher','open');wait(lambda:snap()['opened'] and snap()['mode']=='apps','launcher reopens in app mode')
|
||||||
|
ipc('launcher','close')
|
||||||
|
print('Emoji picker: >emoji switches in place, grid of six rows, search, copy, IPC toggle passed.')
|
||||||
|
finally:
|
||||||
|
shell.terminate()
|
||||||
|
try:shell.wait(5)
|
||||||
|
except subprocess.TimeoutExpired:shell.kill()
|
||||||
|
if saved.returncode==0:
|
||||||
|
restore=subprocess.Popen(['wl-copy'],stdin=subprocess.PIPE,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,start_new_session=True)
|
||||||
|
restore.stdin.write(saved.stdout);restore.stdin.close()
|
||||||
@@ -112,7 +112,7 @@ Terminal={'true' if suffix=='Terminal' else 'false'}
|
|||||||
ipc('launcherTest','key',ESC)
|
ipc('launcherTest','key',ESC)
|
||||||
eventually(lambda:not snapshot()['visible'],'Escape dismiss')
|
eventually(lambda:not snapshot()['visible'],'Escape dismiss')
|
||||||
open_launcher();query('>')
|
open_launcher();query('>')
|
||||||
eventually(lambda:{r['id'] for r in snapshot()['results']}=={'about','appearance','audio','bar','tray','bluetooth','controlcenter','display','dock','launcher','media','metrics','network','notifications','power','wallpaper','widgets','osd','lock','dashboard','plugins','clipboard'},'all commands registered')
|
eventually(lambda:{r['id'] for r in snapshot()['results']}=={'about','appearance','audio','bar','tray','bluetooth','controlcenter','display','dock','launcher','media','metrics','network','notifications','power','wallpaper','widgets','osd','lock','dashboard','plugins','clipboard','emoji'},'all commands registered')
|
||||||
time.sleep(.3);assert ipc('launcherTest','screenshot',str(ROOT/'.cache/launcher-preview.png'))
|
time.sleep(.3);assert ipc('launcherTest','screenshot',str(ROOT/'.cache/launcher-preview.png'))
|
||||||
for text,page in [('>metrics','metrics'),('>dock','dock'),('>media','media'),('>tray','tray'),('>display','displays'),('>launcher','launcher'),('>appearance','appearance'),('>bar','bar'),('>network','network'),('>bluetooth','bluetooth'),('>audio','audio'),('>controlcenter','controlcenter'),('>notifications','notifications'),('>power','power'),('>about','about')]:
|
for text,page in [('>metrics','metrics'),('>dock','dock'),('>media','media'),('>tray','tray'),('>display','displays'),('>launcher','launcher'),('>appearance','appearance'),('>bar','bar'),('>network','network'),('>bluetooth','bluetooth'),('>audio','audio'),('>controlcenter','controlcenter'),('>notifications','notifications'),('>power','power'),('>about','about')]:
|
||||||
query(text)
|
query(text)
|
||||||
|
|||||||
Reference in new issue
Block a user