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,15 +15,19 @@ interface AutoStart {
disable(): void;
}
const isFlatpak = process.env.FLATPAK_ID !== undefined;
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");
return {
isEnabled: () => existsSync(file),
isEnabled: () => existsSync(file), // TODO: flatpak
wasAutoStarted: () => process.argv.includes("--autostart"),
enable() {
if (isFlatpak) {
} else {
const desktopFile = `
[Desktop Entry]
Type=Application
@ -37,8 +41,14 @@ StartupNotify=false
mkdirSync(dir, { recursive: true });
writeFileSync(file, desktopFile);
}
},
disable: () => rmSync(file, { force: true })
disable: () => {
if (isFlatpak) {
} else {
rmSync(file, { force: true });
}
}
};
}