chore: prep for flatpak

This commit is contained in:
Lewis Crichton 2023-12-09 23:09:54 +00:00
parent 894ec4b902
commit bb09596485
No known key found for this signature in database

View file

@ -15,16 +15,20 @@ interface AutoStart {
disable(): void; disable(): void;
} }
const isFlatpak = process.env.FLATPAK_ID !== undefined;
function makeAutoStartLinux(): AutoStart { function makeAutoStartLinux(): AutoStart {
const configDir = process.env.XDG_CONFIG_HOME || join(process.env.HOME!, ".config"); const configDir = process.env.XDG_CONFIG_HOME || join(process.env.HOME!, ".config");
const dir = join(configDir, "autostart"); const dir = join(configDir, "autostart");
const file = join(dir, "vencord.desktop"); const file = join(dir, "vencord.desktop");
return { return {
isEnabled: () => existsSync(file), isEnabled: () => existsSync(file), // TODO: flatpak
wasAutoStarted: () => process.argv.includes("--autostart"), wasAutoStarted: () => process.argv.includes("--autostart"),
enable() { enable() {
const desktopFile = ` if (isFlatpak) {
} else {
const desktopFile = `
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Version=1.0 Version=1.0
@ -35,10 +39,16 @@ Terminal=false
StartupNotify=false StartupNotify=false
`.trim(); `.trim();
mkdirSync(dir, { recursive: true }); mkdirSync(dir, { recursive: true });
writeFileSync(file, desktopFile); writeFileSync(file, desktopFile);
}
}, },
disable: () => rmSync(file, { force: true }) disable: () => {
if (isFlatpak) {
} else {
rmSync(file, { force: true });
}
}
}; };
} }