feat: spawn application process via compositor

This commit is contained in:
wxlyyy
2026-02-02 00:37:22 +08:00
parent 7fef627415
commit c095b78ef4
8 changed files with 73 additions and 8 deletions
+10 -2
View File
@@ -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
View File
@@ -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) {
+8
View File
@@ -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);
}
}
}
+8
View File
@@ -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);
}
}
}
+8
View File
@@ -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);
}
}
}
+8
View File
@@ -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);
}
}
}