Discord: Difference between revisions

Frontear (talk | contribs)
reformat a large chunk of this page to improve formatting
Scrumplex (talk | contribs)
m Add information about Wayland screen sharing with Discord Canary
 
(2 intermediate revisions by 2 users not shown)
Line 36: Line 36:
Enhances Discord desktop app with new features. Nixpkgs provides the installer via <code>pkgs.betterdiscordctl</code>. This can be added to your configuration, though users may prefer to instead run it one-off via the [[Nix]] cli.<syntaxhighlight lang="bash">
Enhances Discord desktop app with new features. Nixpkgs provides the installer via <code>pkgs.betterdiscordctl</code>. This can be added to your configuration, though users may prefer to instead run it one-off via the [[Nix]] cli.<syntaxhighlight lang="bash">
$ nix-shell -p betterdiscordctl --command 'betterdiscordctl install' # nix-legacy
$ nix-shell -p betterdiscordctl --command 'betterdiscordctl install' # nix-legacy
$ nix run nixpkgs#betterdiscordctl -- install # nix3-cli
$ nix run nixpkgs#betterdiscordctl -- install # nix3


$ nix-shell -p betterdiscordctl --command 'betterdiscordctl self-upgrade' # nix-legacy
$ nix-shell -p betterdiscordctl --command 'betterdiscordctl self-upgrade' # nix-legacy
$ nix run nixpkgs#betterdiscordctl -- self-upgrade # nix3-cli
$ nix run nixpkgs#betterdiscordctl -- self-upgrade # nix3
</syntaxhighlight>
</syntaxhighlight>


Line 79: Line 79:
== Troubleshooting ==
== Troubleshooting ==


=== Screensharing on Wayland ===
=== Screen sharing on Wayland ===
Discord's screen sharing capabilities have been broken for [https://support.discord.com/hc/en-us/community/posts/360047644231-Native-Wayland-Support?page=2#comments 5 years with no official fix]. The most consistent fix involves using the web version of Discord alongside a browser that supports screen sharing in Wayland, like [[Firefox]]. Alternatively, you can use an [[Discord#Unofficial Clients|unofficial client]] like ''Webcord'' or ''Vesktop'', both of which have fixed this issue in their own ways.
Since December 2024, Discord Canary supports screen sharing on Wayland. Alternatively, you can use the web version on a browser that supports screen sharing on Wayland, or an [[Discord#Unofficial Clients|unofficial client]] like ''Webcord'' or ''Vesktop'', both of which have fixed this issue in their own ways.
{{Note|Remember to configure an [https://wiki.archlinux.org/title/XDG_Desktop_Portal#List_of_backends_and_interfaces XDG Desktop Portal] with screen cast capabilities!}}
{{Note|Remember to configure an [https://wiki.archlinux.org/title/XDG_Desktop_Portal#List_of_backends_and_interfaces XDG Desktop Portal] with screen cast capabilities!}}


Line 103: Line 103:
}}
}}


=== Opening Links with Firefox ===
=== Krisp noise suppression ===
If you use Discord and it silently fails to open links in Firefox, you possibly have encountered [https://github.com/NixOS/nixpkgs/issues/78961 issue #78961]. This is caused by a version mismatch between the NSS libraries used by Discord and Firefox. Luckily, a relatively easy workaround is available:
The Krisp noise suppression option will not work on NixOS because the Discord binary is patched before installation, and there is a DRM-style integrity check in the Krisp binary which prevents Krisp from working if the Discord binary is modified. See https://github.com/NixOS/nixpkgs/issues/195512 for details.


First, find out which NSS version Firefox is currently using with
==== Python Script Workaround ====
<syntaxhighlight lang="console">
{{Warning|The usage of such modifications goes against Discord's [https://discord.com/terms Terms of Service] and  Krisp's [https://krisp.ai/terms-of-use/ Terms of Use] and can result in your Discord account being terminated and/or being banned from using Krisp's services!}}
$ nix path-info $(which firefox) -r | grep nss-
</syntaxhighlight>


This should print a few store paths, focus on their ends, which should look like <code>nss-x.xx</code>. We're interested in the one with the newest version. Next, create a new file called <code>discord_patched.nix</code> and paste the following code into it:
One way to enable Krisp noise suppression is by patching the <code>discord_krisp.node</code> binary to bypass its DRM verification. Below is a Nix configuration that creates a Python script that patches the binary by modifying specific bytes to bypass the license check: <syntaxhighlight lang="nixos">{ pkgs, ... }:
<syntaxhighlight lang="nix">
let
with import <nixpkgs> {};
  krisp-patcher =
 
    pkgs.writers.writePython3Bin "krisp-patcher"
pkgs.discord.override {
      {
     nss = pkgs.nss_3_49_2;
        libraries = with pkgs.python3Packages; [
          capstone
          pyelftools
        ];
        flakeIgnore = [
          "E501" # line too long (82 > 79 characters)
          "F403" # 'from module import *' used; unable to detect undefined names
          "F405" # name may be undefined, or defined from star imports: module
        ];
      }
      (
        builtins.readFile (
          pkgs.fetchurl {
            url = "https://pastebin.com/raw/8tQDsMVd";
            sha256 = "sha256-IdXv0MfRG1/1pAAwHLS2+1NESFEz2uXrbSdvU9OvdJ8=";
          }
        )
      );
in
{
  environment.systemPackages = [
     krisp-patcher
  ];
}
}
</syntaxhighlight>
</syntaxhighlight>


Now replace <code>nss_3_49_2</code> with the previously looked up version's "attribute name", which you can look up [https://search.nixos.org/packages/?query=nss_ here]. Finally, build and install this patched package with
{{Note|As of version 0.0.76, the script works. But, future versions of Discord may break the script. Therefore, you should not rely on this script for long-term use. For the latest updates and more details, follow https://github.com/NixOS/nixpkgs/issues/195512.}}
<syntaxhighlight lang="console">
$ export NIXPKGS_ALLOW_UNFREE=1; nix-env -i $(nix-build discord_patched.nix) --arg config '{ allowUnfree = true; }'
</syntaxhighlight>


Log in again and you should be able to open links properly.
After adding this to your Nix configuration and rebuilding, make sure Discord is completely closed, and then run:
<pre>$ krisp-patcher ~/.config/discord/0.0.76/modules/discord_krisp/discord_krisp.node</pre>


=== Krisp noise suppression ===
Once you restart Discord and join a VC, you should see a sound wave icon to the left of the hangup icon.
The Krisp noise suppression option will not work on NixOS because the Discord binary is patched before installation, and there is a DRM-style integrity check in the Krisp binary which prevents Krisp from working if the Discord binary is modified. See https://github.com/NixOS/nixpkgs/issues/195512 for details.


=== Text-to-Speech ===
=== Text-to-Speech ===
Line 135: Line 152:
(pkgs.discord.override { withTTS = true; })
(pkgs.discord.override { withTTS = true; })
</syntaxhighlight>
</syntaxhighlight>
== Links ==
[https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/discord/default.nix default.nix for discord]
[[Category:Applications]]
[[Category:Applications]]
[[Category:Gaming]]
[[Category:Gaming]]