mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 16:32:50 -05:00
launcher: allow launch prefix to run in shell
This commit is contained in:
@@ -137,21 +137,42 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// * Apps
|
function escapeShellArg(arg) {
|
||||||
|
return "'" + arg.replace(/'/g, "'\\''") + "'"
|
||||||
|
}
|
||||||
|
|
||||||
|
function needsShellExecution(prefix) {
|
||||||
|
if (!prefix || prefix.length === 0) return false
|
||||||
|
return /[;&|<>()$`\\"']/.test(prefix)
|
||||||
|
}
|
||||||
|
|
||||||
function launchDesktopEntry(desktopEntry, usePrimeRun) {
|
function launchDesktopEntry(desktopEntry, usePrimeRun) {
|
||||||
let cmd = desktopEntry.command
|
let cmd = desktopEntry.command
|
||||||
if (usePrimeRun && hasPrimeRun) {
|
if (usePrimeRun && hasPrimeRun) {
|
||||||
cmd = ["prime-run"].concat(cmd)
|
cmd = ["prime-run"].concat(cmd)
|
||||||
}
|
}
|
||||||
if (SettingsData.launchPrefix && SettingsData.launchPrefix.length > 0) {
|
|
||||||
const launchPrefix = SettingsData.launchPrefix.trim().split(" ")
|
const prefix = SettingsData.launchPrefix?.trim() || ""
|
||||||
|
|
||||||
|
if (prefix.length > 0 && needsShellExecution(prefix)) {
|
||||||
|
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ")
|
||||||
|
const shellCmd = `${prefix} ${escapedCmd}`
|
||||||
|
|
||||||
|
Quickshell.execDetached({
|
||||||
|
command: ["sh", "-c", shellCmd],
|
||||||
|
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME"),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (prefix.length > 0) {
|
||||||
|
const launchPrefix = prefix.split(" ")
|
||||||
cmd = launchPrefix.concat(cmd)
|
cmd = launchPrefix.concat(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
Quickshell.execDetached({
|
Quickshell.execDetached({
|
||||||
command: cmd,
|
command: cmd,
|
||||||
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME"),
|
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME"),
|
||||||
});
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function launchDesktopAction(desktopEntry, action, usePrimeRun) {
|
function launchDesktopAction(desktopEntry, action, usePrimeRun) {
|
||||||
@@ -159,15 +180,28 @@ Singleton {
|
|||||||
if (usePrimeRun && hasPrimeRun) {
|
if (usePrimeRun && hasPrimeRun) {
|
||||||
cmd = ["prime-run"].concat(cmd)
|
cmd = ["prime-run"].concat(cmd)
|
||||||
}
|
}
|
||||||
if (SettingsData.launchPrefix && SettingsData.launchPrefix.length > 0) {
|
|
||||||
const launchPrefix = SettingsData.launchPrefix.trim().split(" ")
|
const prefix = SettingsData.launchPrefix?.trim() || ""
|
||||||
|
|
||||||
|
if (prefix.length > 0 && needsShellExecution(prefix)) {
|
||||||
|
const escapedCmd = cmd.map(arg => escapeShellArg(arg)).join(" ")
|
||||||
|
const shellCmd = `${prefix} ${escapedCmd}`
|
||||||
|
|
||||||
|
Quickshell.execDetached({
|
||||||
|
command: ["sh", "-c", shellCmd],
|
||||||
|
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME"),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (prefix.length > 0) {
|
||||||
|
const launchPrefix = prefix.split(" ")
|
||||||
cmd = launchPrefix.concat(cmd)
|
cmd = launchPrefix.concat(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
Quickshell.execDetached({
|
Quickshell.execDetached({
|
||||||
command: cmd,
|
command: cmd,
|
||||||
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME"),
|
workingDirectory: desktopEntry.workingDirectory || Quickshell.env("HOME"),
|
||||||
});
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// * Session management
|
// * Session management
|
||||||
|
|||||||
Reference in New Issue
Block a user