mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
impl basic launcher command plugin
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user