Skip to content

Instantly share code, notes, and snippets.

@irishgordo
Forked from Shika-B/fix_discord.md
Created January 8, 2023 20:52
Show Gist options
  • Save irishgordo/1e0efb66071ffac6b5cb6194e93da6bf to your computer and use it in GitHub Desktop.
Save irishgordo/1e0efb66071ffac6b5cb6194e93da6bf to your computer and use it in GitHub Desktop.
Discord lagging during long calls on Linux

My discord was lagging increasingly during long calls on my Manjaro installation. I searched a bit on the Wiki but the fix shared there didn't work for. What worked for me is this answer on the Discord support forum, that I will detail a bit here. Start by moving to the right folder:

cd ~/.config/discord/<your_version>/modules/discord_desktop_core

Then, depending on whether you are a javascript developer or not, you may need to install the npm package of your distribution. On Arch/Manjaro, yay -S npm will do. Once this is done, unpack the core.asar file with

npx asar extract core.asar core

then open the discord_desktop_core folder with your favorite editor. Now we need to change two things.

  • Change the setTrayIcon in the discord_desktop_core/core/app/systemTray.js file so that it does nothing
  • Update the discord_desktop_core/index.js file to make it look for a core folder instead of a core.asar file

For the first part, open the file and replace the function with

function setTrayIcon(icon) {
  return;
  // Keep track of last set icon
  currentIcon = trayIcons[icon]; // If icon is null, hide the tray icon.  Otherwise show
  // These calls also check for tray existence, so minimal cost.

  if (icon == null) {
    hide();
    return;
  } else {
    show();
  } // Keep mute/deafen menu items in sync with client, based on icon states


  const muteIndex = contextMenu.indexOf(menuItems[MenuItems.MUTE]);
  const deafenIndex = contextMenu.indexOf(menuItems[MenuItems.DEAFEN]);
  const voiceConnected = contextMenu[muteIndex].visible;
  let shouldSetContextMenu = false;

  if (currentIcon !== trayIcons.DEFAULT && currentIcon !== trayIcons.UNREAD) {
    // Show mute/deaf controls
    if (!voiceConnected) {
      contextMenu[muteIndex].visible = true;
      contextMenu[deafenIndex].visible = true;
      shouldSetContextMenu = true;
    }

    if (currentIcon === trayIcons.DEAFENED) {
      contextMenu[muteIndex].checked = true;
      contextMenu[deafenIndex].checked = true;
      shouldSetContextMenu = true;
    } else if (currentIcon === trayIcons.MUTED) {
      contextMenu[muteIndex].checked = true;
      contextMenu[deafenIndex].checked = false;
      shouldSetContextMenu = true;
    } else if (contextMenu[muteIndex].checked || contextMenu[deafenIndex].checked) {
      contextMenu[muteIndex].checked = false;
      contextMenu[deafenIndex].checked = false;
      shouldSetContextMenu = true;
    }
  } else if (voiceConnected) {
    contextMenu[muteIndex].visible = false;
    contextMenu[deafenIndex].visible = false;
    shouldSetContextMenu = true;
  }

  shouldSetContextMenu && setContextMenu();
  atomTray != null && atomTray.setImage(_electron.nativeImage.createFromPath(currentIcon));
}

For the second part, replace the require call in the index.js file with

module.exports = require('./core');

Close any instance of discord you have running (be sure to close it and not just minimize it, in case you're not sure reboot your computer) and reopen Discord. You will probably need to apply this fix at each Discord update.

@SuperbMuffin
Copy link

Why did you fork it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment