GooseMod / OpenAsar

Open-source alternative of Discord desktop's app.asar

Home Page:https://openasar.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flatpak build of Discord doesn't draw title bar under GNOME Wayland, possibly because OpenAsar overrides the parameters.

musabagriyanik opened this issue · comments

I don't know if OpenAsar is exactly overriding them but when OpenAsar installed there's no title bar under GNOME Wayland. Electron apps needs to have --enable-features=WaylandWindowDecorations to have title bar working under GNOME Wayland environment. Because of this, the flatpak build of Discord uses a startup script that passes those required parameters to the Discord process. It looks like, a parameter that only exists in flatpak script still works, but if the parameter exists in both flatpak script and OpenAsar (--enable-features in this case) the flatpak parameters are getting overridden by OpenAsar.

https://github.com/GooseMod/OpenAsar/blob/main/src/cmdSwitches.js
https://github.com/flathub/com.discordapp.Discord/blob/master/discord.sh#L9

Try setting "cmdPreset": "none manually in Discord's settings.json and see if it works.

tried that, still no borders

@CanadaHonk no, that's unrelated and irrelevant.

What you need is --enable-features=WaylandWindowDecorations. Power users will generally know to pass this flag by themselves (e.g. in Arch, it is customary to package all Chromium/Electron-based apps with launchers that read additional flags from ~/.config/<appname>-flags.conf and/or ~/.config/electron<version>-flags.conf), but this does not work here because OpenAsar overwrites those flags with their own.

Note that Electron does not merge --{enable,disable}-features= flags by itself, e.g. a command line of --enable-features=A --enable-features=B will result in only feature B enabled.


What you need is something like this code (this is taken from my personal patch of upstream Discord bootstrap.js for proper handling of --disable-features, you need the same but but in both ways):

// user-provided --enable-features= override our --disable-features=
if (app.commandLine.hasSwitch('enable-features')) {
  const features = app.commandLine.getSwitchValue('enable-features').split(',');
  disabledFeatures = disabledFeatures.filter(f => !features.includes(f));
}
// user-provided --disable-features= are merged with our --disable-features=
if (app.commandLine.hasSwitch('disable-features')) {
  const features = app.commandLine.getSwitchValue('disable-features').split(',');
  app.commandLine.removeSwitch('disable-features');
  disabledFeatures.push(...features);
}
console.log(`XXX: updating switch: --disable-features=${disabledFeatures.join(',')}`)
app.commandLine.appendSwitch('disable-features', disabledFeatures.join(','));