Skip to content

[EPIC] Snap and Flatpak compatibility #157

@QbDesu

Description

@QbDesu

The BetterDiscord installer doesn't support Flatpak or Snap. The first Linux distros start seemlessly integrating these types of packages in their software store and as their main method of installation.

Well, to be fair saying that the installer doesn't support snap isn't quite right either. Rather it explicitly blocks installing to snap even though it would otherwise be supported.

if (proposedPath.includes("/snap/")) {
remote.dialog.showErrorBox("BetterDiscord Incompatible", "BetterDiscord is currently incompatible with Snap installs of Discord. Support for snap installs is coming soon!");
return "";
}

Flatpak on the other hand actually needs some more work because of it's sandboxing by the looks of it. More specifically it can't read the betterdiscord.asar from user's config directory, so it needs to be installed in the flatpak's config directory.

The snap installation has a related problem. because it's betterdiscord.asar is in the user config directory while the detected config directory is in the snap package's directory the autoupdate functionality of BD is expected to fail.

From a chat with @Tropix126 I could gather that it wasn't always compatible but changing it to injection method to inject the require statement in the discord_desktop_core/index.js module seems to have made it otherwise compatible. In fact betterdiscordctl's installation method is identical to the installer. The only relevant change for BD installation is changing the config directory detection depending on the detected.

betterdiscordctl's installation steps for comparison (warning: identical to the installer)
  1. Detect config directory
  2. Detect Discord folder in the config directory
  3. Detect version folder in the Discord config directory
  4. Detect the core module folder in the version directory
  5. download betterdiscord.asar from github releases (it looks like it may also be caching the asar though)
  6. create a betterdiscord and betterdiscord/data folder if they don't exist
  7. copy the asar in there
  8. inject require statement in index.js of the core module (only difference I can see is a newline more after the injection using betterdiscordctl)
  • Techincal Requirements
    • Snap support
    • Flatpak support
      • version folder detection (same as snap)
      • install to betterdiscord.asar to the package's home directory
        • check if package update removes the BD config folderwhen doing so
    • BetterDiscord compatibility?
      • BetterDiscord seems to function fine on snap and flatpak but maybe there are details that don't function correctly because they require accessing files outside of the BD config directory
  • Design/UX considerations
    • should the list be exanded to include snap/flatpak?
    • should snap/flatpak be fallback if for automatic detection if the native installation is not found?
    • should snap/flatpak be in separate platform selection dialogs?
      • if so how should those be accessed?
        • keep in mind lots of people won't know what type of installation they have because the software stores of their distro's make it seemless. they probably won't even know what the hell snap/flatpak is. but would still be nice to choose which variant to install to
    • technical: adjustments to internal data structure to keep it clean
      • internal platform name + folderName + display name + image url separate, so you don't need to do .toLowercase().replace(" ","") everywhere
        • also don't hardcode the existing platforms everywhere but base them of a common object where all are defined, this would also allow adding a Discord - Snap and Discord - Flatpak platform as needed,

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions