Compare commits

...

3 commits

Author SHA1 Message Date
Lewis Crichton
bb09596485
chore: prep for flatpak 2023-12-09 23:09:54 +00:00
Lewis Crichton
894ec4b902
chore: lint 2023-12-09 23:01:35 +00:00
Lewis Crichton
dd44602730
fix: make minimize only run on autostart 2023-12-09 23:00:47 +00:00
2 changed files with 23 additions and 9 deletions

View file

@ -10,38 +10,51 @@ import { join } from "path";
interface AutoStart { interface AutoStart {
isEnabled(): boolean; isEnabled(): boolean;
wasAutoStarted(): boolean;
enable(): void; enable(): void;
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"),
enable() { enable() {
const desktopFile = ` if (isFlatpak) {
} else {
const desktopFile = `
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Version=1.0 Version=1.0
Name=Vencord Name=Vencord
Comment=Vencord autostart script Comment=Vencord autostart script
Exec=${process.execPath} Exec=${process.execPath} --autostart
Terminal=false 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 });
}
}
}; };
} }
const autoStartWindowsMac: AutoStart = { const autoStartWindowsMac: AutoStart = {
isEnabled: () => app.getLoginItemSettings().openAtLogin, isEnabled: () => app.getLoginItemSettings().openAtLogin,
wasAutoStarted: () => app.getLoginItemSettings().wasOpenedAtLogin,
enable: () => app.setLoginItemSettings({ openAtLogin: true }), enable: () => app.setLoginItemSettings({ openAtLogin: true }),
disable: () => app.setLoginItemSettings({ openAtLogin: false }) disable: () => app.setLoginItemSettings({ openAtLogin: false })
}; };

View file

@ -24,6 +24,7 @@ import type { SettingsStore } from "shared/utils/SettingsStore";
import { ICON_PATH } from "../shared/paths"; import { ICON_PATH } from "../shared/paths";
import { createAboutWindow } from "./about"; import { createAboutWindow } from "./about";
import { initArRPC } from "./arrpc"; import { initArRPC } from "./arrpc";
import { autoStart } from "./autoStart";
import { import {
DATA_DIR, DATA_DIR,
DEFAULT_HEIGHT, DEFAULT_HEIGHT,
@ -442,8 +443,8 @@ function createMainWindow() {
const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js")));
export async function createWindows() { export async function createWindows() {
const { startMinimized } = Settings.store; const shouldStartMinimized = Settings.store.startMinimized && autoStart.wasAutoStarted();
const splash = createSplashWindow(startMinimized); const splash = createSplashWindow(shouldStartMinimized);
// SteamOS letterboxes and scales it terribly, so just full screen it // SteamOS letterboxes and scales it terribly, so just full screen it
if (isDeckGameMode) splash.setFullScreen(true); if (isDeckGameMode) splash.setFullScreen(true);
await ensureVencordFiles(); await ensureVencordFiles();
@ -454,7 +455,7 @@ export async function createWindows() {
mainWin.webContents.on("did-finish-load", () => { mainWin.webContents.on("did-finish-load", () => {
splash.destroy(); splash.destroy();
if (!startMinimized || isDeckGameMode) mainWin!.show(); if (!shouldStartMinimized || isDeckGameMode) mainWin!.show();
if (isDeckGameMode) { if (isDeckGameMode) {
// always use entire display // always use entire display