impl basic launcher command plugin

This commit is contained in:
Altyrost
2025-12-07 00:30:54 +01:00
parent 969bddd382
commit 37ed52f52f
3 changed files with 56 additions and 0 deletions
+3
View File
@@ -728,6 +728,9 @@
"calculator-enter-expression": "Enter a mathematical expression",
"calculator-error": "Error",
"calculator-name": "Calculator",
"command": "Command",
"command-name": "Command",
"command-description": "Run shell commands",
"clipboard": "Clipboard history",
"clipboard-clear-description": "Clear all clipboard history",
"clipboard-clear-description-full": "Remove all items from clipboard history",
+8
View File
@@ -320,6 +320,14 @@ SmartPanel {
}
}
CommandPlugin {
id: cmdPlugin
Component.onCompleted: {
registerPlugin(this);
Logger.d("Launcher", "Registered: CommandPlugin");
}
}
EmojiPlugin {
id: emojiPlugin
Component.onCompleted: {
@@ -0,0 +1,45 @@
import QtQuick
import Quickshell
import qs.Commons
Item {
property var launcher: null
property string name: I18n.tr("plugins.command")
function handleCommand(query) {
return query.startsWith(">cmd");
}
function commands() {
return [
{
"name": ">cmd",
"description": I18n.tr("plugins.command-description"),
"icon": "utilities-terminal",
"isImage": false,
"onActivate": function () {
launcher.setSearchText(">cmd ");
}
}
];
}
function getResults(query) {
if (!query.startsWith(">cmd"))
return [];
let expression = query.substring(4).trim();
return [
{
"name": I18n.tr("plugins.command-name"),
"description": I18n.tr("plugins.command-description"),
"icon": "utilities-terminal",
"isImage": false,
"onActivate": function () {
launcher.close();
Quickshell.execDetached(["sh", "-c", expression]);
}
}
];
}
}