Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CustomDiscordIcon] Doesn't work on macOS/Linux. #10

Closed
Kyza opened this issue Aug 26, 2019 · 15 comments
Closed

[CustomDiscordIcon] Doesn't work on macOS/Linux. #10

Kyza opened this issue Aug 26, 2019 · 15 comments
Labels
CustomDiscordIcon Wontfix This will not be worked on

Comments

@Kyza
Copy link
Owner

Kyza commented Aug 26, 2019

CustomDiscordIcon doesn't work on macOS.

Also!

I have noted that CustomDiscordIcon also only works when the icons in your Windows taskbar are expanded. I will be looking into this to see if I can fix it.

Example of an expanded icon:

One more thing!

Read the discussion below on CustomDiscordIcon and Linux.
#10 (comment)

@Kyza Kyza added Wontfix This will not be worked on CustomDiscordIcon labels Aug 26, 2019
@issue-label-bot issue-label-bot bot added the Bug Something isn't working label Aug 26, 2019
@Kyza Kyza removed the Bug Something isn't working label Aug 26, 2019
@Kyza Kyza pinned this issue Aug 26, 2019
Repository owner deleted a comment from issue-label-bot bot Aug 26, 2019
@Kyza Kyza closed this as completed Aug 26, 2019
@ObserverOfTime
Copy link

Doesn't seem to be working on Linux either.

Uncaught Error: Could not call remote method 'setIcon'. Check that the method signature is correct. Underlying error: Error processing argument at index 0, conversion failure from /usr/share/icons/hicolor48x48/apps/steam.png
Underlying stack: TypeError: Error processing argument at index 0, conversion failure from /usr/share/icons/hicolor48x48/apps/steam.png
    at /opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:370:67
    at EventEmitter.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:249:27)
    at EventEmitter.emit (events.js:200:13)
    at WebContents.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/api/web-contents.js:342:29)
    at WebContents.emit (events.js:200:13)

    at /opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:373:21
    at EventEmitter.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/rpc-server.js:249:27)
    at EventEmitter.emit (events.js:200:13)
    at WebContents.<anonymous> (/opt/discord-ptb/resources/electron.asar/browser/api/web-contents.js:342:29)
    at WebContents.emit (events.js:200:13)

@Kyza
Copy link
Owner Author

Kyza commented Sep 18, 2019

Can you confirm that the PNG is actually a PNG and not a different format hiding in a PNG file?

@ObserverOfTime
Copy link

Yes, it's a PNG.

/usr/share/icons/hicolor/48x48/apps/steam.png: PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced

I noticed that the path in the error log is missing a slash even though it's there in the input field. 🤔

@Kyza
Copy link
Owner Author

Kyza commented Sep 18, 2019

While I try to figure out exactly why that slash is not there, could you try adding an extra slash where the single one is?

@ObserverOfTime
Copy link

No error. Still not working.

@Kyza
Copy link
Owner Author

Kyza commented Sep 18, 2019

This is strange, I can even use this path on my Windows system.

/Users/Name/Desktop/discord.png

@Kyza
Copy link
Owner Author

Kyza commented Sep 18, 2019

Try this version and tell me what path it prints in the console.

CustomDiscordIcon.prototype.getSettingsPanel = function() {
  var settingsWrapper = document.createElement("div");
  settingsWrapper.setAttribute("style", "width; 100%; height: auto;");


  // Here is the toggle for using the guild and DM icons.
  // Checked   = valueChecked-m-4IJZ
  // Unchecked = valueUnchecked-2lU_20
  var useGuildIcon = document.createElement("div");
  useGuildIcon.setAttribute("id", "useGuildIcon");

  var useGuildIconText = document.createElement("div");
  useGuildIconText.setAttribute("id", "useGuildIconText");

  var useGuildIconInput = document.createElement("input");
  useGuildIconInput.setAttribute("id", "useGuildIconInput");

  useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
  useGuildIcon.setAttribute("tabindex", "0");
  useGuildIcon.setAttribute("style", "flex: 0 0 auto; width: 250px; margin-bottom: 10px;");
  useGuildIcon.onclick = () => {
    if (useGuildIcon.getAttribute("class") == "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX") {
      useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
      useGuildIconInput.setAttribute("checked", "false");
    } else {
      useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
      useGuildIconInput.setAttribute("checked", "true");
    }
    saveSettings();
  };
  // Make sure that the checkbox is set to the correct value when it is created.
  if (loadSettings().useGuildIcons) {
    useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
    useGuildIconInput.setAttribute("checked", "true");
  } else {
    useGuildIcon.setAttribute("class", "flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX");
    useGuildIconInput.setAttribute("checked", "false");
  }

  useGuildIconText.innerHTML = "Use Guild & DM Icons";
  useGuildIconText.setAttribute("style", "position: absolute; text-align: center; width: 100%; height: 100%; line-height: 22.5px;");
  useGuildIconInput.setAttribute("class", "checkboxEnabled-CtinEn checkbox-2tyjJg da-checkboxEnabled da-checkbox");
  useGuildIconInput.setAttribute("type", "checkbox");
  useGuildIconInput.setAttribute("tabindex", "-1");
  useGuildIconInput.setAttribute("checked", "false");
  useGuildIconInput.setAttribute("style", "margin-left: auto; margin-right: auto;");
  useGuildIcon.appendChild(useGuildIconText);
  useGuildIcon.appendChild(useGuildIconInput);



  var iconPath = document.createElement("input");
  iconPath.setAttribute("id", "custom-icon-path");
  iconPath.setAttribute("placeholder", "Enter the path to the image.");
  iconPath.setAttribute("type", "text");
  iconPath.setAttribute("style", "width: 100%; height: 30px; border-width: 0px; border-radius: 10px; background-color: rgba(255, 255, 255, 0.7); padding-left: 10px; margin-bottom: 10px;");

  var errorHTML = "<br>Your image must use a standard format such as <strong>PNG or JPG</strong>.<br>Animated GIFs are not supported and never will be.<br>Your image can't be a URL to something online, it has to ba saved somewhere.";
  iconPath.oninput = () => {
    saveSettings();

    try {
			console.log(document.getElementById("custom-icon-path").value);
      win.setIcon(document.getElementById("custom-icon-path").value);
      removeError();
    } catch (e) {
      settingsWrapper.appendChild(createError(errorHTML));
    }
  };

  var title = document.createElement("h1");
  title.setAttribute("style", "font-size: 1.5em; margin-bottom: 20px;");
  title.innerHTML = `<strong>CustomDiscordIcon Settings</strong>`;
  settingsWrapper.appendChild(title);

  settingsWrapper.appendChild(useGuildIcon);
  settingsWrapper.appendChild(iconPath);
  iconPath.value = (loadSettings() == undefined ? "" : loadSettings().customImagePath);

  // Try setting the icon right away.
	setTimeout(() => {
		try {
			console.log(document.getElementById("custom-icon-path").value);
			win.setIcon(document.getElementById("custom-icon-path").value);
			removeError();
		} catch (e) {
			settingsWrapper.appendChild(createError(errorHTML));
		}
	}, 100);

  BdApi.showToast("CustomDiscordIcon: Your settings will be saved automatically.", {});

  return settingsWrapper;
};

@ObserverOfTime
Copy link

ObserverOfTime commented Sep 18, 2019

You could have posted a patch instead of the entire file.

@Kyza
Copy link
Owner Author

Kyza commented Sep 18, 2019

I changed it, just replace the getSettingsPanel function.

@ObserverOfTime
Copy link

ObserverOfTime commented Sep 18, 2019

Nothing in the logs. This is in the config file.

{
  "useGuildIcons": false,
  "customImagePath": "/usr/share/icons/hicolor/48x48/apps/steam.png"
}

Switching useGuildIcon to true, I get the same error but the path is /home/$USER/.config/BetterDiscord/plugins/icon.png. Normally, you should be saving this file in a temporary directory:

path.join(os.tmpdir(), 'CustomDiscordIcon.png')

@ObserverOfTime
Copy link

ObserverOfTime commented Sep 18, 2019

Anyway, my guess is you simply can't modify the icon on Linux because it either uses a file from Discord's directory, or a file provided by the system's icon theme. Both of which are normally owned by root.

@Kyza
Copy link
Owner Author

Kyza commented Sep 18, 2019

That's possible, but it doesn't explain why the slash was missing from the path earlier.

I'll need more Linux users to confirm.

@ObserverOfTime
Copy link

Yeah, I don't know about that one. ¯\_(ツ)_/¯

@Kyza Kyza changed the title [CustomDiscordIcon] Doesn't work on macOS. [CustomDiscordIcon] Doesn't work on macOS/Linux. Sep 18, 2019
@Shinare-I
Copy link

I don't know what else to say, but as a linux user, I can confirm it does not work.
I am running Ubuntu 18.04 on Unity desktop environment

@ludmtn
Copy link

ludmtn commented Oct 25, 2019

Hello, I do not understand how to change the photo of Discord, can you help me? (I am on Windows so no problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CustomDiscordIcon Wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants