From 0beb74fad0a0accb55799deb211d5ab1e16e620d Mon Sep 17 00:00:00 2001 From: Takase <20792268+takase1121@users.noreply.github.com> Date: Sat, 27 Apr 2024 03:22:17 +0800 Subject: [PATCH] Allow users to pass --enable/disable-features flag (#527) Previously they would be overwritten by vesktop --- src/main/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 325d417..2f8191c 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -27,10 +27,13 @@ process.env.VENCORD_USER_DATA_DIR = DATA_DIR; function init() { const { disableSmoothScroll, hardwareAcceleration } = Settings.store; + const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(","); + const disabledFeatures = app.commandLine.getSwitchValue("disable-features").split(","); + if (hardwareAcceleration === false) { app.disableHardwareAcceleration(); } else { - app.commandLine.appendSwitch("enable-features", "VaapiVideoDecodeLinuxGL,VaapiVideoEncoder,VaapiVideoDecoder"); + enabledFeatures.push("VaapiVideoDecodeLinuxGL", "VaapiVideoEncoder", "VaapiVideoDecoder"); } if (disableSmoothScroll) { @@ -43,11 +46,16 @@ 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" ); + 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";