mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Compositor: adjust launch command logic (#1742)
This commit is contained in:
@@ -524,18 +524,21 @@ Item {
|
||||
|
||||
// Defer execution to next event loop iteration to ensure panel is fully closed
|
||||
Qt.callLater(() => {
|
||||
Logger.d("ApplicationsProvider", `Launching: ${app.name}`);
|
||||
Logger.d("ApplicationsProvider", `Launching: ${app.name} (App ID: ${app.id || "unknown"})`);
|
||||
|
||||
if (Settings.data.appLauncher.customLaunchPrefixEnabled && Settings.data.appLauncher.customLaunchPrefix) {
|
||||
// Use custom launch prefix
|
||||
const prefix = Settings.data.appLauncher.customLaunchPrefix.split(" ");
|
||||
Logger.d("ApplicationsProvider", `Using custom launch prefix: ${Settings.data.appLauncher.customLaunchPrefix}`);
|
||||
|
||||
if (app.runInTerminal) {
|
||||
const terminal = Settings.data.appLauncher.terminalCommand.split(" ");
|
||||
const command = prefix.concat(terminal.concat(app.command));
|
||||
Logger.d("ApplicationsProvider", `Executing command (with prefix and terminal): ${command.join(" ")}`);
|
||||
Quickshell.execDetached(command);
|
||||
} else {
|
||||
const command = prefix.concat(app.command);
|
||||
Logger.d("ApplicationsProvider", `Executing command (with prefix): ${command.join(" ")}`);
|
||||
Quickshell.execDetached(command);
|
||||
}
|
||||
} else if (Settings.data.appLauncher.useApp2Unit && ProgramCheckerService.app2unitAvailable && app.id) {
|
||||
@@ -550,10 +553,13 @@ Item {
|
||||
Logger.d("ApplicationsProvider", "Executing terminal app manually: " + app.name);
|
||||
const terminal = Settings.data.appLauncher.terminalCommand.split(" ");
|
||||
const command = terminal.concat(app.command);
|
||||
Logger.d("ApplicationsProvider", "Executing command (manual terminal): " + command.join(" "));
|
||||
CompositorService.spawn(command);
|
||||
} else if (app.command && app.command.length > 0) {
|
||||
Logger.d("ApplicationsProvider", "Executing command: " + app.command.join(" "));
|
||||
CompositorService.spawn(app.command);
|
||||
} else if (app.execute) {
|
||||
Logger.d("ApplicationsProvider", "Calling app.execute() for: " + app.name);
|
||||
app.execute();
|
||||
} else {
|
||||
Logger.w("ApplicationsProvider", `Could not launch: ${app.name}. No valid launch method.`);
|
||||
|
||||
@@ -41,6 +41,7 @@ Item {
|
||||
"onActivate": function () {
|
||||
launcher.closeImmediately();
|
||||
Qt.callLater(() => {
|
||||
Logger.d("CommandProvider", "Executing shell command: " + expression);
|
||||
Quickshell.execDetached(["sh", "-c", expression]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -418,13 +418,17 @@ Singleton {
|
||||
|
||||
// Spawn command
|
||||
function spawn(command) {
|
||||
// Ensure command is a proper JS array (QML lists can behave unexpectedly in some contexts)
|
||||
const cmdArray = Array.isArray(command) ? command : (command && typeof command === "object" && command.length !== undefined) ? Array.from(command) : [command];
|
||||
|
||||
Logger.d("CompositorService", `Spawning: ${cmdArray.join(" ")}`);
|
||||
if (backend && backend.spawn) {
|
||||
backend.spawn(command);
|
||||
backend.spawn(cmdArray);
|
||||
} else {
|
||||
try {
|
||||
Quickshell.execDetached(command);
|
||||
Quickshell.execDetached(cmdArray);
|
||||
} catch (e) {
|
||||
Logger.e("Compositor", "Failed to exececute detached:", e);
|
||||
Logger.e("CompositorService", "Failed to execute detached:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +493,8 @@ Item {
|
||||
|
||||
function spawn(command) {
|
||||
try {
|
||||
Quickshell.execDetached(["hyprctl", "dispatch", "--", "exec"].concat(command));
|
||||
const cmdArray = Array.isArray(command) ? command : (command && typeof command === "object" && command.length !== undefined) ? Array.from(command) : [command];
|
||||
Quickshell.execDetached(["hyprctl", "dispatch", "--", "exec"].concat(cmdArray));
|
||||
} catch (e) {
|
||||
Logger.e("HyprlandService", "Failed to spawn command:", e);
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ Item {
|
||||
|
||||
function spawn(command) {
|
||||
try {
|
||||
// Convert QML list to JS array if needed (QML lists fail Array.isArray but have length)
|
||||
// Ensure command is a proper JS array
|
||||
const cmdArray = Array.isArray(command) ? command : (command && typeof command === "object" && command.length !== undefined) ? Array.from(command) : [command];
|
||||
const cmdStr = cmdArray.join(" ");
|
||||
Quickshell.execDetached(["sh", "-c", "mmsg -d 'spawn," + cmdStr + "'"]);
|
||||
|
||||
@@ -501,7 +501,10 @@ Item {
|
||||
|
||||
function spawn(command) {
|
||||
try {
|
||||
Quickshell.execDetached(["niri", "msg", "action", "spawn", "--"].concat(command));
|
||||
const cmdArray = Array.isArray(command) ? command : (command && typeof command === "object" && command.length !== undefined) ? Array.from(command) : [command];
|
||||
const niriCommand = ["niri", "msg", "action", "spawn", "--"].concat(cmdArray);
|
||||
Logger.d("NiriService", "Calling niri spawn: " + niriCommand.join(" "));
|
||||
Quickshell.execDetached(niriCommand);
|
||||
} catch (e) {
|
||||
Logger.e("NiriService", "Failed to spawn command:", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user