From 48fbca26a8297b61912733d9ffef5e071d29422d Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Sun, 21 Apr 2024 07:40:33 +0800 Subject: [PATCH] merge both enable-features and disable-features flags --- src/main/index.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index d06da2b..2f8191c 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -27,12 +27,13 @@ process.env.VENCORD_USER_DATA_DIR = DATA_DIR; function init() { const { disableSmoothScroll, hardwareAcceleration } = Settings.store; - const enableFeatures: string[] = []; + const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(","); + const disabledFeatures = app.commandLine.getSwitchValue("disable-features").split(","); if (hardwareAcceleration === false) { app.disableHardwareAcceleration(); } else { - enableFeatures.push("VaapiVideoDecodeLinuxGL", "VaapiVideoEncoder", "VaapiVideoDecoder"); + enabledFeatures.push("VaapiVideoDecodeLinuxGL", "VaapiVideoEncoder", "VaapiVideoDecoder"); } if (disableSmoothScroll) { @@ -45,15 +46,15 @@ function init() { // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service. // // WidgetLayering (Vencord Added): Fix DevTools context menus https://github.com/electron/electron/issues/38790 - app.commandLine.appendSwitch( - "disable-features", - "WinRetrieveSuggestionsOnlyOnDemand,HardwareMediaKeyHandling,MediaSessionService,WidgetLayering" + disabledFeatures.push( + "WinRetrieveSuggestionsOnlyOnDemand", + "HardwareMediaKeyHandling", + "MediaSessionService", + "WidgetLayering" ); - // don't overwrite command-line supplied switches - if (!app.commandLine.hasSwitch("enable-features")) { - app.commandLine.appendSwitch("enable-features", enableFeatures.join(",")); - } + app.commandLine.appendSwitch("enable-features", [...new Set(enabledFeatures)].filter(Boolean).join(",")); + app.commandLine.appendSwitch("disable-features", [...new Set(disabledFeatures)].filter(Boolean).join(",")); // In the Flatpak on SteamOS the theme is detected as light, but SteamOS only has a dark mode, so we just override it if (isDeckGameMode) nativeTheme.themeSource = "dark";