Fix not launching on GNOME

Reference: https://github.com/electron/electron/issues/46538
Also improves the chromium switch code
This commit is contained in:
Vendicated
2025-05-14 05:25:52 +02:00
parent e760e58ed7
commit fc16fc5404

View File

@@ -28,23 +28,26 @@ console.log("Vesktop v" + app.getVersion());
// Make the Vencord files use our DATA_DIR // Make the Vencord files use our DATA_DIR
process.env.VENCORD_USER_DATA_DIR = DATA_DIR; process.env.VENCORD_USER_DATA_DIR = DATA_DIR;
const isLinux = process.platform === "linux";
function init() { function init() {
app.setAsDefaultProtocolClient("discord"); app.setAsDefaultProtocolClient("discord");
const { disableSmoothScroll, hardwareAcceleration } = Settings.store; const { disableSmoothScroll, hardwareAcceleration } = Settings.store;
const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(","); const enabledFeatures = new Set(app.commandLine.getSwitchValue("enable-features").split(","));
const disabledFeatures = app.commandLine.getSwitchValue("disable-features").split(","); const disabledFeatures = new Set(app.commandLine.getSwitchValue("disable-features").split(","));
if (hardwareAcceleration === false) { if (hardwareAcceleration === false) {
app.disableHardwareAcceleration(); app.disableHardwareAcceleration();
} else { } else {
enabledFeatures.push( enabledFeatures.add("AcceleratedVideoEncoder");
"AcceleratedVideoDecodeLinuxGL", enabledFeatures.add("AcceleratedVideoDecoder");
"AcceleratedVideoEncoder",
"AcceleratedVideoDecoder", if (isLinux) {
"AcceleratedVideoDecodeLinuxZeroCopyGL" enabledFeatures.add("AcceleratedVideoDecodeLinuxGL");
); enabledFeatures.add("AcceleratedVideoDecodeLinuxZeroCopyGL");
}
} }
if (disableSmoothScroll) { if (disableSmoothScroll) {
@@ -58,22 +61,34 @@ function init() {
app.commandLine.appendSwitch("disable-background-timer-throttling"); app.commandLine.appendSwitch("disable-background-timer-throttling");
app.commandLine.appendSwitch("disable-backgrounding-occluded-windows"); app.commandLine.appendSwitch("disable-backgrounding-occluded-windows");
if (process.platform === "win32") { if (process.platform === "win32") {
disabledFeatures.push("CalculateNativeWinOcclusion"); disabledFeatures.add("CalculateNativeWinOcclusion");
} }
// work around chrome 66 disabling autoplay by default // work around chrome 66 disabling autoplay by default
app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
// WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows. // WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows.
// HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service. // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service.
// //
// WidgetLayering (Vencord Added): Fix DevTools context menus https://github.com/electron/electron/issues/38790 // WidgetLayering (Vencord Added): Fix DevTools context menus https://github.com/electron/electron/issues/38790
disabledFeatures.push("WinRetrieveSuggestionsOnlyOnDemand", "HardwareMediaKeyHandling", "MediaSessionService"); disabledFeatures.add("WinRetrieveSuggestionsOnlyOnDemand");
disabledFeatures.add("HardwareMediaKeyHandling");
disabledFeatures.add("MediaSessionService");
// Support TTS on Linux using speech-dispatcher if (isLinux) {
app.commandLine.appendSwitch("enable-speech-dispatcher"); // Support TTS on Linux using https://wiki.archlinux.org/title/Speech_dispatcher
app.commandLine.appendSwitch("enable-speech-dispatcher");
app.commandLine.appendSwitch("enable-features", [...new Set(enabledFeatures)].filter(Boolean).join(",")); // Work around Gtk-ERROR: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported
app.commandLine.appendSwitch("disable-features", [...new Set(disabledFeatures)].filter(Boolean).join(",")); // https://github.com/electron/electron/issues/46538
// TODO: Remove this when upstream fixes it
app.commandLine.appendSwitch("gtk-version", "3");
}
disabledFeatures.forEach(feat => enabledFeatures.delete(feat));
app.commandLine.appendSwitch("enable-features", [...enabledFeatures].filter(Boolean).join(","));
app.commandLine.appendSwitch("disable-features", [...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 // 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"; if (isDeckGameMode) nativeTheme.themeSource = "dark";