diff --git a/scripts/start.ts b/scripts/start.ts index 72ce3ab..21660b0 100644 --- a/scripts/start.ts +++ b/scripts/start.ts @@ -8,4 +8,4 @@ import "./utils/dotenv"; import { spawnNodeModuleBin } from "./utils/spawn.mjs"; -spawnNodeModuleBin("electron", [".", ...(process.env.ELECTRON_LAUNCH_FLAGS?.split(" ") ?? [])]); +spawnNodeModuleBin("electron", [process.cwd(), ...(process.env.ELECTRON_LAUNCH_FLAGS?.split(" ") ?? [])]); diff --git a/src/main/autoStart.ts b/src/main/autoStart.ts index fbbc30e..19d7e00 100644 --- a/src/main/autoStart.ts +++ b/src/main/autoStart.ts @@ -5,7 +5,7 @@ */ import { app } from "electron"; -import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs"; +import { existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from "fs"; import { join } from "path"; interface AutoStart { @@ -17,7 +17,16 @@ interface AutoStart { function makeAutoStartLinux(): AutoStart { const configDir = process.env.XDG_CONFIG_HOME || join(process.env.HOME!, ".config"); const dir = join(configDir, "autostart"); - const file = join(dir, "vencord.desktop"); + const file = join(dir, "vesktop.desktop"); + + // IM STUPID + const legacyName = join(dir, "vencord.desktop"); + if (existsSync(legacyName)) renameSync(legacyName, file); + + // "Quoting must be done by enclosing the argument between double quotes and escaping the double quote character, + // backtick character ("`"), dollar sign ("$") and backslash character ("\") by preceding it with an additional backslash character" + // https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables + const commandLine = process.argv.map(arg => '"' + arg.replace(/["$`\\]/g, "\\$&") + '"').join(" "); return { isEnabled: () => existsSync(file), @@ -25,12 +34,11 @@ function makeAutoStartLinux(): AutoStart { const desktopFile = ` [Desktop Entry] Type=Application -Version=1.0 -Name=Vencord -Comment=Vencord autostart script -Exec=${process.execPath} -Terminal=false +Name=Vesktop +Comment=Vesktop autostart script +Exec=${commandLine} StartupNotify=false +Terminal=false `.trim(); mkdirSync(dir, { recursive: true });