mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #1653 from bokicoder/compositor-spawn
feat: spawn application process via compositor
This commit is contained in:
@@ -395,9 +395,17 @@ Item {
|
||||
Logger.d("Taskbar", "Executing terminal app manually: " + app.name);
|
||||
const terminal = Settings.data.appLauncher.terminalCommand.split(" ");
|
||||
const command = terminal.concat(app.command);
|
||||
Quickshell.execDetached(command);
|
||||
try {
|
||||
CompositorService.spawn(command);
|
||||
} catch (e) {
|
||||
Quickshell.execDetached(command);
|
||||
}
|
||||
} else if (app.command && app.command.length > 0) {
|
||||
Quickshell.execDetached(app.command);
|
||||
try {
|
||||
CompositorService.spawn(app.command);
|
||||
} catch (e) {
|
||||
Quickshell.execDetached(app.command);
|
||||
}
|
||||
} else if (app.execute) {
|
||||
app.execute();
|
||||
} else {
|
||||
|
||||
+11
-3
@@ -6,6 +6,7 @@ import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Widgets
|
||||
import qs.Commons
|
||||
import qs.Services.Compositor
|
||||
import qs.Services.System
|
||||
import qs.Services.UI
|
||||
import qs.Widgets
|
||||
@@ -1054,13 +1055,20 @@ Loader {
|
||||
} else {
|
||||
// Fallback logic when app2unit is not used
|
||||
if (app.runInTerminal) {
|
||||
// If app.execute() fails for terminal apps, we handle it manually.
|
||||
Logger.d("Dock", "Executing terminal app manually: " + app.name);
|
||||
const terminal = Settings.data.appLauncher.terminalCommand.split(" ");
|
||||
const command = terminal.concat(app.command);
|
||||
Quickshell.execDetached(command);
|
||||
try {
|
||||
CompositorService.spawn(command);
|
||||
} catch (e) {
|
||||
Quickshell.execDetached(command);
|
||||
}
|
||||
} else if (app.command && app.command.length > 0) {
|
||||
Quickshell.execDetached(app.command);
|
||||
try {
|
||||
CompositorService.spawn(app.command);
|
||||
} catch (e) {
|
||||
Quickshell.execDetached(app.command);
|
||||
}
|
||||
} else if (app.execute) {
|
||||
app.execute();
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,7 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Commons
|
||||
import qs.Services.Compositor
|
||||
import qs.Services.System
|
||||
|
||||
Item {
|
||||
@@ -580,13 +581,20 @@ Item {
|
||||
} else {
|
||||
// Fallback logic when app2unit is not used
|
||||
if (app.runInTerminal) {
|
||||
// If app.execute() fails for terminal apps, we handle it manually.
|
||||
Logger.d("ApplicationsProvider", "Executing terminal app manually: " + app.name);
|
||||
const terminal = Settings.data.appLauncher.terminalCommand.split(" ");
|
||||
const command = terminal.concat(app.command);
|
||||
Quickshell.execDetached(command);
|
||||
try {
|
||||
CompositorService.spawn(command);
|
||||
} catch (e) {
|
||||
Quickshell.execDetached(command);
|
||||
}
|
||||
} else if (app.command && app.command.length > 0) {
|
||||
Quickshell.execDetached(app.command);
|
||||
try {
|
||||
CompositorService.spawn(app.command);
|
||||
} catch (e) {
|
||||
Quickshell.execDetached(app.command);
|
||||
}
|
||||
} else if (app.execute) {
|
||||
app.execute();
|
||||
} else {
|
||||
|
||||
@@ -405,6 +405,15 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn command
|
||||
function spawn(command) {
|
||||
if (backend && backend.spawn) {
|
||||
backend.spawn(command);
|
||||
} else {
|
||||
throw new Error("No backend available for spawn command");
|
||||
}
|
||||
}
|
||||
|
||||
// Session management
|
||||
function logout() {
|
||||
if (backend && backend.logout) {
|
||||
|
||||
@@ -485,4 +485,12 @@ Item {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function spawn(command) {
|
||||
try {
|
||||
Quickshell.execDetached(["hyprctl", "dispatch", "--", "exec"].concat(command));
|
||||
} catch (e) {
|
||||
Logger.e("HyprlandService", "Failed to spawn command:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,4 +688,12 @@ Item {
|
||||
// }
|
||||
// return null;
|
||||
}
|
||||
|
||||
function spawn(command) {
|
||||
try {
|
||||
Quickshell.execDetached(["mmsg", "-d", "spawn", "--"].concat(command));
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Failed to spawn command:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,4 +498,12 @@ Item {
|
||||
// }
|
||||
// return null;
|
||||
}
|
||||
|
||||
function spawn(command) {
|
||||
try {
|
||||
Quickshell.execDetached(["niri", "msg", "action", "spawn", "--"].concat(command));
|
||||
} catch (e) {
|
||||
Logger.e("NiriService", "Failed to spawn command:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,4 +572,12 @@ Item {
|
||||
// }
|
||||
// return null;
|
||||
}
|
||||
|
||||
function spawn(command) {
|
||||
try {
|
||||
Quickshell.execDetached(["swaymsg", "exec", "--"].concat(command));
|
||||
} catch (e) {
|
||||
Logger.e("SwayService", "Failed to spawn command:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user