Open QbDesu opened 3 years ago
Flatpak on the other hand actually needs some more work because of it's sandboxing by the looks of it.
Snap is also sandboxed.
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.
This is, unfortunately, true.
Fedora and Ubuntu, two of the biggest distros, according to Panic! at the Distro, now prefer installing through Flatpak and Snap respectively.
Yet another reason to use Arch.
Yet another reason to use Arch.
The solution is not to use Arch. This isn't an Arch vs. other distros thread. Please keep your distro supremacy out of here and make actually useful comments.
The solution in Fedora is to actually use DNF instead of some dumb GUI that may use flatpak. The solution in Ubuntu is to do yourself a favour and migrate to a decent distro.
I have just installed discord via flatpak on my arch based distro and it seems currently installing betterdiscord into the flatpak is not a trivial task and basically not supported? I tried passing the path to the discord executable or the discord directory to npm run inject
, but that does not seem to be a thing I can do...
Is currently the only option to install via AUR or can I actually get betterdiscord working on the flatpak somehow?
I have just installed discord via flatpak on my arch based distro and it seems currently installing betterdiscord into the flatpak is not a trivial task and basically not supported? I tried passing the path to the discord executable or the discord directory to
npm run inject
, but that does not seem to be a thing I can do... Is currently the only option to install via AUR or can I actually get betterdiscord working on the flatpak somehow?
ahh, the betterdiscord installer I guess can't handle it, but the (older?) betterdiscordctl can do it? (https://gist.github.com/ObserverOfTime/d7e60eb9aa7fe837545c8cb77cf31172)
Hey... I don't see what all the fuss is about and why this has been discussed for years, or even why anyone needs or trusts those "fancy" "betterdiscordctl" or "BetterDiscord-Installer.AppImage" tools anyway. It's literally just 1 little .asar
file that needs to be placed in the Discord folder, and one little config edit. No need for all that hassle or all those bloated applications just to do such a simple little job.
DISC_CONFIG="$HOME/.var/app/com.discordapp.Discord/config/discord" && BD_ASAR=betterdiscord.asar && wget --timestamping -P "${DISC_CONFIG}/../BetterDiscord/data" -- "https://github.com/BetterDiscord/BetterDiscord/releases/latest/download/${BD_ASAR}" && DISC_VER="$(ls --sort=time --time=creation "${DISC_CONFIG}" | grep -E -m 1 '^[0-9]+\.[0-9]+\.[0-9]+$')" && echo -e "require('../../../../BetterDiscord/data/${BD_ASAR}');\nmodule.exports = require('./core.asar');" | tee "${DISC_CONFIG}/${DISC_VER}/modules/discord_desktop_core/index.js" && echo -e "\nBetterDiscord installed. Restart Discord if currently running." || echo -e "\nInstallation failed."
DISC_CONFIG
variable at the start of the line, by only modifying the path that comes after HOME/
..var/app/com.discordapp.Discord/config/discord
.config/discord
.var/app/com.discordapp.DiscordCanary/config/discordcanary
.config/discordcanary
Just run that command, and it will do the following:
betterdiscord.asar
file modification timestamp.betterdiscord.asar
into Discord's loader script for the latest installed Discord version (version is auto-detected).That's it. Just save this command somewhere. Run it once. That's it. Run it again when you want to update BetterDiscord. You can run it as many times as you want, since it won't change anything if BetterDiscord is already installed and up-to-date.
You can even make an alias in your ~/.zshrc
or ~/.bashrc
if you want to easily run this command in your terminal anytime in the future:
alias betterdiscord-update="DISC_CONFIG=\"\$HOME/.var/app/com.discordapp.Discord/config/discord\" && BD_ASAR=betterdiscord.asar && wget --timestamping -P \"\${DISC_CONFIG}/../BetterDiscord/data\" -- \"https://github.com/BetterDiscord/BetterDiscord/releases/latest/download/\${BD_ASAR}\" && DISC_VER=\"\$(ls --sort=time --time=creation \"\${DISC_CONFIG}\" | grep -E -m 1 '^[0-9]+\\.[0-9]+\\.[0-9]+\$')\" && echo -e \"require('../../../../BetterDiscord/data/\${BD_ASAR}');\\nmodule.exports = require('./core.asar');\" | tee \"\${DISC_CONFIG}/\${DISC_VER}/modules/discord_desktop_core/index.js\" && echo -e \"\\nBetterDiscord installed. Restart Discord if currently running.\" || echo -e \"\\nInstallation failed.\""
(Be sure to set your personal DISC_CONFIG
path here if you aren't using the default Flatpak version of Discord.)
Note that GitHub presents oneliners as a very long line. Be sure to copy these correctly, or use the "copy text" button that GitHub provides.
As for long-term usage and updates, it's very simple too: When Discord starts up, BetterDiscord always does a version check and shows a popup screen to let you know when a new version is available.
In some situations, Discord updates will break BetterDiscord so that it doesn't load at all, and in that case you won't see any notification, but you'll easily notice that BetterDiscord isn't working anymore. In that case, simply run my command to update BetterDiscord to the latest version.
In both scenarios, it's literally brainless. You don't have to think at all. You just look at the built-in Discord notification saying that a new BetterDiscord version is available, or you notice that BetterDiscord is suddenly broken, and you do the update.
It's that easy! :star:
Have fun! I hope this helps someone else who just wants a simple, clean and totally safe way to install BetterDiscord for Linux Flatpaks and Native alike, while also helping you effortlessly install BD regardless of whether you use Discord or the Discord CANARY client! This is important since CANARY isn't supported by any of the other installation tools. :beach_umbrella:
In fact, if you're using the Flatpak version of Discord together with my installation method, then you will be totally protected along every step of the way, for both the installation of BetterDiscord itself (there's no malicous code in my script, which is super easy to audit), and you'll also be protected for the usage of all 3rd party plugins inside BetterDiscord itself (since they will run inside the Flatpak sandbox and won't be able to steal all your personal files). That's the installation method that I would recommend to people! :heart_decoration:
@ObserverOfTime LMFAO. You're the guy who made "betterdiscordctl". I noticed that you downvoted my clean solution 30 minutes after I posted it. The amount of saltiness in you doing without a word is hilarious. I'll upvote myself just to annoy you even more. :kiss:
It's always amusing seeing someone so confidently proclaim, "that code is so bloated! just use this: {700 character unreadable one-liner with a quarter the functionality".
@Parent5446 You seriously mean that you work at Google yet are incapable of reading two shell commands? One wget
to download BetterDiscord, and one tee
to write it to Discord's loader.
And I would rather be 45 easily audited, clean words (652 characters) than the 670 awfully written, self-updating spaghetti LINES (20661 characters/2301 words) with such awful newbie practices such as hard-coding the absolute path to the BetterDiscord.asar, meaning that Discord breaks if it's moved, lmfao.
Seriously, the hard-coded path is astonishing since the default index.js literally contains a relative path already, as if to hint "hey, use a relative path, dummy". But not only is it bloated and shoddily written. You also have to trust the author never to add malware to it.
Both solutions install BetterDiscord into any Discord or Canary client. What else exactly do you need? 😂 My solution also supports the Discord CANARY Flatpak by the way, unlike the one you use. So my one-liner has more features.
In fact, my solution does error checking along every step of the installation, so it is completely reliable.
Seriously, what else do you need? If you are gonna say "uninstallation" then lmao, why would you uninstall BetterDiscord? And if you do, then it is literally just a matter of deleting the BetterDiscord folder and removing the reference to it from Discord's index.js. Something that doesn't need a script, since it is super obvious from the one-liner exactly where that file resides. But again, why would anyone uninstall BetterDiscord? It is literally a better version of Discord.
I will never use your bloated, pointless script for something so easily solved in 45 words.
Hey... I don't see what all the fuss is about and why this has been discussed for years, or even why anyone needs or trusts those "fancy" "betterdiscordctl" or "BetterDiscord-Installer.AppImage" tools anyway. It's literally just 1 little
.asar
file that needs to be placed in the Discord folder, and one little config edit. No need for all that hassle or all those bloated applications just to do such a simple little job.
as an end user I prefer graphical applications. And betterdiscordctl is at least readable and easy to use. Instead of complaining and posting a lengthy comment, that nobody cares about, how about you fork betterdicordctl and give a PR back to fix the issues you have with it. (e.g. don't hardcode paths, etc.) OR, PR this installer and fix the issues in it...
If you don't wanna do either of those, then at least you could have written your comment not as toxic as you did. Just say you would rather use a single line of stacked commands and anyone, who prefers that, there u go. No need to be so toxic. ^^
Thoughts on your code being "unreliable spaghetti with awful newbie practices". @bb010g
Please direct design criticism of betterdiscordctl
at me, not @ObserverOfTime.
And I would rather be 45 easily audited, clean words (652 characters) than the 670 awfully written, self-updating spaghetti LINES (20661 characters/2301 words) with such awful newbie practices such as hard-coding the absolute path to the BetterDiscord.asar, meaning that Discord breaks if it's moved, lmfao.
237 lines are help text & argument parsing. The argument parsing is extremely boilerplate & easily auditable. Bash is not a great language.
66 lines are semver parsing & comparison for the auto-updating functionality, which you can disable in one line, and is disabled when betterdiscordctl
is packaged. I'm trying to be robust here. Bash is not a great language.
I would love to have a better updating system than the current setup, and when available, I'd recommend using betterdiscordctl
through your distribution's package manager (which will not auto-update). The current self-updating system works and doesn't waste bandwidth.
I do believe that betterdiscordctl
has very good code for a Bash script, and that it behaves very well as a Unix CLI tool.
betterdiscordctl status
is useful for debugging, and can tell you when stuff is messed up when BetterDiscord changes installation methods, which has happened. betterdiscordctl
has also cleaned up properly after itself after BetterDiscord changed installation methods.
Seriously, the hard-coded path is astonishing since the default index.js literally contains a relative path already, as if to hint "hey, use a relative path, dummy". But not only is it bloated and shoddily written. You also have to trust the author never to add malware to it.
$bd_asar
sits under $bd_config/data/$bd_asar_name
. $bd_config
is found at $xdg_config/BetterDiscord
. We write to $d_modules/discord_desktop_core/index.js
. $d_modules
can be user-specified via --d-modules <d_modules>
, but it defaults to the lexicographically greatest path matching "$d_config/"+([0-9]).+([0-9]).+([0-9])/modules
. $d_config
is found at $xdg_config/discord${d_flavor,,}
if not using Flatpak or Snap, and found at $xdg_config/discord
if using Flatpak or Snap. So, a relative path (pivoting at $xdg_config
) could be used if $d_modules
is not user-specified, but the current behavior is more consistent and has not caused reported issues so far. For now, it's not a priority. If you move $XDG_CONFIG_HOME
without running betterdiscordctl reinstall
, you are correct that it will break.
You do have to trust me not to add malware to it. If you want to manually review changes, disable auto-update.
Both solutions install BetterDiscord into any Discord or Canary client. What else exactly do you need? 😂 My solution also supports the Discord CANARY Flatpak by the way, unlike the one you use. So my one-liner has more features.
This is an open issue (https://github.com/bb010g/betterdiscordctl/issues/143). I've been busy with work, but will get to this in the next few days if nobody else does first.
Seriously, what else do you need? If you are gonna say "uninstallation" then lmao, why would you uninstall BetterDiscord? And if you do, then it is literally just a matter of deleting the BetterDiscord folder and removing the reference to it from Discord's index.js. Something that doesn't need a script, since it is super obvious from the one-liner exactly where that file resides. But again, why would anyone uninstall BetterDiscord? It is literally a better version of Discord.
This may be simple for technical users, but not everyone wants to bother discovering how BetterDiscord's internals work, and betterdiscordctl
is useful there. Even if you do know how it works, it can be handy. It's your choice on whether to use it or not. I still like having an easy option available that's more lightweight than an Electron-based installer.
If someone wants to uninstall BetterDiscord, betterdiscordctl
respects that. I don't presume to know people's reasons.
@TayouVR
OR, PR this installer and fix the issues in it...
Sure, I'll have a look at fixing the BetterDiscord-Installer code.
@bb010g Don't worry, you're in good company. The BetterDiscord-Installer code is spaghetti too, such as defining static variables with dynamic values outside functions, using dynamic data that is created inside other functions, and then using those global, static variables as input data for functions that take ZERO arguments, all while passing data to other scripts by importing those scripts so that they inherit the variables (rather than using function parameters). It's a total... mess.
In pseudocode, BetterDiscord-Installer does things like this:
// file: core.js:
const discordPath = getDiscordPath();
require("./install.js");
// file: install.js:
const bdFile = path.join(discordPath, "BetterDiscord.asar");
function write() {
writeto(bdFile);
}
They literally forgot how passing arguments works. :rofl: It will make it a bit trickier to fix the bugs and untangle some of this mess. I'll see about making BetterDiscord-Installer work on Linux again, and adding Flatpak support to it. The code is a mess but it shouldn't be too terrible to rewrite the spaghetti parts that are involved with paths and installation. :+1:
Edit: It's done. Releasing the pull request tomorrow since it's time to sleep.
Edit: Today, instead of submitting the pull request, I decided to throw in a lot more surprises for people (you'll have to wait and see, otherwise it wouldn't be a surprise). But I didn't have much time today since this is a project that I don't personally use, and I have a lot of other important things to do. But everything related to BetterDiscord-Installer is done now, and the pull request and an AppImage for users will be released tomorrow!
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. https://github.com/BetterDiscord/Installer/blob/1bf733dbb989c00ecf17a755ef931fa961195812/src/renderer/actions/paths.js#L84-L87 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 thediscord_desktop_core/index.js
module seems to have made it otherwise compatible. In factbetterdiscordctl
'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)
.toLowercase().replace(" ","")
everywhereDiscord - Snap
andDiscord - Flatpak
platform as needed,