From dd446027304ed0545d04271114e482c0731c27a8 Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sat, 9 Dec 2023 23:00:47 +0000 Subject: [PATCH 1/3] fix: make minimize only run on autostart --- src/main/autoStart.ts | 7 +++++-- src/main/mainWindow.ts | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/autoStart.ts b/src/main/autoStart.ts index fbbc30e..9c0b885 100644 --- a/src/main/autoStart.ts +++ b/src/main/autoStart.ts @@ -10,6 +10,7 @@ import { join } from "path"; interface AutoStart { isEnabled(): boolean; + wasAutoStarted(): boolean; enable(): void; disable(): void; } @@ -21,6 +22,7 @@ function makeAutoStartLinux(): AutoStart { return { isEnabled: () => existsSync(file), + wasAutoStarted: () => process.argv.includes("--autostart"), enable() { const desktopFile = ` [Desktop Entry] @@ -28,7 +30,7 @@ Type=Application Version=1.0 Name=Vencord Comment=Vencord autostart script -Exec=${process.execPath} +Exec=${process.execPath} --autostart Terminal=false StartupNotify=false `.trim(); @@ -42,8 +44,9 @@ StartupNotify=false const autoStartWindowsMac: AutoStart = { isEnabled: () => app.getLoginItemSettings().openAtLogin, + wasAutoStarted: () => app.getLoginItemSettings().wasOpenedAtLogin, enable: () => app.setLoginItemSettings({ openAtLogin: true }), - disable: () => app.setLoginItemSettings({ openAtLogin: false }) + disable: () => app.setLoginItemSettings({ openAtLogin: false }), }; export const autoStart = process.platform === "linux" ? makeAutoStartLinux() : autoStartWindowsMac; diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 6e9a05c..629c82b 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -39,6 +39,7 @@ import { createSplashWindow } from "./splash"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; import { applyDeckKeyboardFix, askToApplySteamLayout, isDeckGameMode } from "./utils/steamOS"; import { downloadVencordFiles, ensureVencordFiles } from "./utils/vencordLoader"; +import { autoStart } from "./autoStart"; let isQuitting = false; let tray: Tray; @@ -442,8 +443,8 @@ function createMainWindow() { const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); export async function createWindows() { - const { startMinimized } = Settings.store; - const splash = createSplashWindow(startMinimized); + const shouldStartMinimized = Settings.store.startMinimized && autoStart.wasAutoStarted(); + const splash = createSplashWindow(shouldStartMinimized); // SteamOS letterboxes and scales it terribly, so just full screen it if (isDeckGameMode) splash.setFullScreen(true); await ensureVencordFiles(); @@ -454,7 +455,7 @@ export async function createWindows() { mainWin.webContents.on("did-finish-load", () => { splash.destroy(); - if (!startMinimized || isDeckGameMode) mainWin!.show(); + if (!shouldStartMinimized || isDeckGameMode) mainWin!.show(); if (isDeckGameMode) { // always use entire display From 894ec4b902e277518d0a21efaafce0067567783d Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sat, 9 Dec 2023 23:01:35 +0000 Subject: [PATCH 2/3] chore: lint --- src/main/autoStart.ts | 2 +- src/main/mainWindow.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/autoStart.ts b/src/main/autoStart.ts index 9c0b885..8a6eaf6 100644 --- a/src/main/autoStart.ts +++ b/src/main/autoStart.ts @@ -46,7 +46,7 @@ const autoStartWindowsMac: AutoStart = { isEnabled: () => app.getLoginItemSettings().openAtLogin, wasAutoStarted: () => app.getLoginItemSettings().wasOpenedAtLogin, enable: () => app.setLoginItemSettings({ openAtLogin: true }), - disable: () => app.setLoginItemSettings({ openAtLogin: false }), + disable: () => app.setLoginItemSettings({ openAtLogin: false }) }; export const autoStart = process.platform === "linux" ? makeAutoStartLinux() : autoStartWindowsMac; diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 629c82b..cd2fd62 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -24,6 +24,7 @@ import type { SettingsStore } from "shared/utils/SettingsStore"; import { ICON_PATH } from "../shared/paths"; import { createAboutWindow } from "./about"; import { initArRPC } from "./arrpc"; +import { autoStart } from "./autoStart"; import { DATA_DIR, DEFAULT_HEIGHT, @@ -39,7 +40,6 @@ import { createSplashWindow } from "./splash"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; import { applyDeckKeyboardFix, askToApplySteamLayout, isDeckGameMode } from "./utils/steamOS"; import { downloadVencordFiles, ensureVencordFiles } from "./utils/vencordLoader"; -import { autoStart } from "./autoStart"; let isQuitting = false; let tray: Tray; From bb0959648586c17cd71cf2f09727547617c2e294 Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sat, 9 Dec 2023 23:09:54 +0000 Subject: [PATCH 3/3] chore: prep for flatpak --- src/main/autoStart.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/autoStart.ts b/src/main/autoStart.ts index 8a6eaf6..dac8e63 100644 --- a/src/main/autoStart.ts +++ b/src/main/autoStart.ts @@ -15,16 +15,20 @@ 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() { - const desktopFile = ` + if (isFlatpak) { + } else { + const desktopFile = ` [Desktop Entry] Type=Application Version=1.0 @@ -35,10 +39,16 @@ Terminal=false StartupNotify=false `.trim(); - mkdirSync(dir, { recursive: true }); - writeFileSync(file, desktopFile); + mkdirSync(dir, { recursive: true }); + writeFileSync(file, desktopFile); + } }, - disable: () => rmSync(file, { force: true }) + disable: () => { + if (isFlatpak) { + } else { + rmSync(file, { force: true }); + } + } }; }