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

Mattermost #704

Closed
rauldipeas opened this issue Aug 28, 2021 · 31 comments · Fixed by #711
Closed

Mattermost #704

rauldipeas opened this issue Aug 28, 2021 · 31 comments · Fixed by #711

Comments

@rauldipeas
Copy link
Contributor

image

varlesh added a commit to PapirusDevelopmentTeam/papirus-icon-theme that referenced this issue Aug 28, 2021
varlesh added a commit that referenced this issue Aug 28, 2021
@varlesh varlesh closed this as completed Aug 28, 2021
@rauldipeas
Copy link
Contributor Author

This needs an update, i'm trying to do it here, but no lucky...

{
    "name": "Mattermost",
    "app_path": [
        "/opt/Mattermost/",
        "/usr/lib/mattermost/"
    ],
    "icons_path": [
        "/opt/Mattermost/resources/",
        "/usr/lib/mattermost/resources/"
    ],
    "binary": "app.asar",
    "script": "electron",
    "icons": {
        "tray-light": {
            "original": "assets/linux/top_bar_light_16.png",
            "theme": "mattermost-tray"
        },
        "tray-light-unread": {
            "original": "assets/linux/top_bar_unread_light_16.png",
            "theme": "mattermost-unread"
        },
        "tray-light-mention": {
            "original": "assets/linux/top_bar_mention_light_16.png",
            "theme": "mattermost-mention"
        },
        "tray-light@2x": {
            "original": "assets/linux/top_bar_light_16@2x.png",
            "theme": "mattermost-tray"
        },
        "tray-light@2x-unread": {
            "original": "assets/linux/top_bar_unread_light_16@2x.png",
            "theme": "mattermost-unread"
        },
        "tray-light@2x-mention": {
            "original": "assets/linux/top_bar_mention_light_16@2x.png",
            "theme": "mattermost-mention"
        },
        "tray-dark": {
            "original": "assets/linux/top_bar_dark_16.png",
            "theme": "mattermost-tray"
        },
        "tray-dark-unread": {
            "original": "assets/linux/top_bar_unread_dark_16.png",
            "theme": "mattermost-unread"
        },
        "tray-dark-mention": {
            "original": "assets/linux/top_bar_mention_dark_16.png",
            "theme": "mattermost-mention"
        },
        "tray-dark@2x": {
            "original": "assets/linux/top_bar_dark_16@2x.png",
            "theme": "mattermost-tray"
        },
        "tray-dark@2x-unread": {
            "original": "assets/linux/top_bar_unread_dark_16@2x.png",
            "theme": "mattermost-unread"
        },
        "tray-dark@2x-mention": {
            "original": "assets/linux/top_bar_mention_dark_16@2x.png",
            "theme": "mattermost-mention"
        }
    }
}
 rauldipeas@IdeaPad-320  ~  sudo hardcode-tray --apply --only mattermost.electron
Welcome to Hardcode-Tray!
Hardcode-Tray replaces some icons on the binary files of some applications. 
Please close all the running applications before running Hardcode-Tray script.
Desktop Environment: Other
Scaling Factor: 1
Icon Size: 24
Icon Theme: Luv
Conversion Tool: RSVGConvert
To Do: Mattermost.Electron
Applying now..


Traceback (most recent call last):
  File "/usr/bin/hardcode-tray", line 121, in <module>
    App.execute()
  File "/usr/lib/python3.7/site-packages/HardcodeTray/app.py", line 120, in execute
    delta = app.do_action(action)
  File "/usr/lib/python3.7/site-packages/HardcodeTray/modules/applications/application.py", line 148, in do_action
    self.install()
  File "/usr/lib/python3.7/site-packages/HardcodeTray/decorators.py", line 58, in wrapper
    func(app)
  File "/usr/lib/python3.7/site-packages/HardcodeTray/modules/applications/application.py", line 96, in install
    self.execute(Action.APPLY)
  File "/usr/lib/python3.7/site-packages/HardcodeTray/modules/applications/helpers/binary.py", line 50, in execute
    self.install_icon(icon, icon_path)
  File "/usr/lib/python3.7/site-packages/HardcodeTray/modules/applications/electron.py", line 41, in install_icon
    self.set_icon(icon, icon_path, png_bytes, True)
  File "/usr/lib/python3.7/site-packages/HardcodeTray/modules/applications/electron.py", line 66, in set_icon
    asar.write(icon_to_replace, png_bytes)
  File "/usr/lib/python3.7/site-packages/HardcodeTray/modules/applications/helpers/asar.py", line 106, in write
    new_files = change_dict_vals(self._header, sizediff, offset0)
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in change_dict_vals
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 244, in <dictcomp>
    d2 = {k: change_dict_vals(v, sizediff, offset) for k, v in d.items()}
  File "/usr/lib/python3.7/site-packages/HardcodeTray/utils.py", line 245, in change_dict_vals
    if d2.get('offset') and int(d2.get('offset')) > offset:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict'

@rauldipeas
Copy link
Contributor Author

image

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

Current release 4.7.2 and i'm not seen your icons on this location:
Screenshot_20210922_040427

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

assets:
Screenshot_20210922_040639

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

ough, it's 5.0.0 RC

@rauldipeas
Copy link
Contributor Author

I'm on version 5.0.0-rc1-13336.

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

similar bug #646

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

downgrade to 4.7.2
i don't know how solve this

@rauldipeas
Copy link
Contributor Author

I'm fixed Gitify manually, with a script that replace files.

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

and #637 to

@rauldipeas
Copy link
Contributor Author

I'm fixing Gitify like this...

npx asar e /opt/Gitify/resources/app.asar app
rsvg-convert /usr/share/icons/Papirus/24x24/panel/gitify-tray-active.svg -o app/assets/images/tray-active.png 
rsvg-convert /usr/share/icons/Papirus/24x24@2x/panel/gitify-tray-active.svg -w 48 -o app/assets/images/tray-active@2x.png 
rsvg-convert /usr/share/icons/Papirus/24x24/panel/gitify-tray.svg -o app/assets/images/tray-idleTemplate.png 
rsvg-convert /usr/share/icons/Papirus/24x24@2x/panel/gitify-tray.svg -w 48 -o app/assets/images/tray-idleTemplate@2x.png
npx asar p app app.asar
sudo cp -rfv app.asar /opt/Gitify/resources/app.asar

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

@acarasimon96 Timothy you know python, maybe you can help solve this error?
I think asar module don't get header bytes for right work on some electron-apps.
TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict'

For test you can use this app. Extract archives and found resources/app.asar file.
This worked:
https://releases.mattermost.com/desktop/4.7.2/mattermost-desktop-4.7.2-linux-x64.tar.gz
This not worked:
https://releases.mattermost.com/desktop/5.0.0-rc1/mattermost-desktop-5.0.0-rc1-linux-x64.tar.gz

@acarasimon96
Copy link
Contributor

acarasimon96 commented Sep 22, 2021

I just successfully ran Hardcode Tray Git version on Mattermost desktop 5.0.0-rc1, but I'm not getting a TypeError on my end. I'm not getting any useful hints either in the debug logs.

It appears that the tray icons in app.asar matches those shown in this comment by the issue creator. If Hardcode Tray really did replace the icons as expected, the icons between light and dark variants in that same directory would be identical.

image

For comparison, here are the icons from Papirus that the script should've used to replace the above:
image

I don't think this looks like an easy fix for me, but it's possible to get it done. This will take a couple days for me to find out the cause and implement a fix since I also have school, chores at home, and other interests to deal with. I apologize for any inconvenience that may arise out of my life situation.

Also, thank you for the unexpected ping, @varlesh. I'm thrilled to be able to help you out with this issue!

Edit: I forgot to upload the debug logfile, so here you go: 2021-09-21 19:36:04.log

@rauldipeas
Copy link
Contributor Author

I'm temporarily using this solution to fix tray icons on my apt repository.
https://gitlab.com/myawesomedistro/madrepo/-/blob/main/scripts/mkpkg/mattermost.sh

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

@acarasimon96 Thanks for your efforts... it's only your desire, I do not insist

@varlesh
Copy link
Collaborator

varlesh commented Sep 22, 2021

I just successfully ran Hardcode Tray Git version on Mattermost desktop 5.0.0-rc1, but I'm not getting a TypeError on my end. I'm not getting any useful hints either in the debug logs

for 5.0.0 RC need use this config

@acarasimon96
Copy link
Contributor

acarasimon96 commented Sep 22, 2021

Oh, I didn't realize to do that first. Now I'm getting the same exact error @rauldipeas got.

@acarasimon96
Copy link
Contributor

I was able to fix the crash, and it was a bit easier than I thought. It was caused by a directory that is literally called "offset" inside app.asar. I changed the code to where it makes sure that the value for "offset" is a string (that is, the real offset value of a file) before recalculating it. However, for some weird reason, I still couldn't get the script to replace the mention and unread icons. I would consider this issue solved once that new bug gets fixed and no other side effects come out of that.

acarasimon96 added a commit to acarasimon96/Hardcode-Tray that referenced this issue Sep 23, 2021
Some Electron apps, such as Mattermost Desktop 5.0.0 (bilelmoussaoui#704), contain a
directory named "offset" in their app.asar files, which is treated
in code as a dict of dicts representing files and subdirectories.
Hardcode Tray expects a string for actual offset values before
recalculating them. This fix adds a check to make sure that it only
performs the said action on offset numbers.
@varlesh
Copy link
Collaborator

varlesh commented Sep 23, 2021

@acarasimon96 glad to hear about success
On logs backup only 16px and 16@2x icons:

[DEBUG] 2021-09-23 06:22:43 Create new backup folder for Mattermost
[DEBUG] 2021-09-23 06:22:43 Creating directory: /home/alex/.config/Hardcode-Tray/Mattermost/2021-09-23 06:22:43/
[DEBUG] 2021-09-23 06:22:43 Executing command: rsvg-convert -f png -o /tmp/tmp9jdsnztd -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-tray.svg
[DEBUG] 2021-09-23 06:22:44 Backup file: /tmp/files|assets|files|linux|files|top_bar_light_16.png to: /home/alex/.config/Hardcode-Tray/Mattermost/2021-09-23 06:22:43/files|assets|files|linux|files|top_bar_light_16.png
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmpx9blhr3j -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-unread.svg
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmpylubzicr -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-mention.svg
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmp3pcydgli -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-tray.svg
[DEBUG] 2021-09-23 06:22:44 Backup file: /tmp/files|assets|files|linux|files|top_bar_light_16@2x.png to: /home/alex/.config/Hardcode-Tray/Mattermost/2021-09-23 06:22:43/files|assets|files|linux|files|top_bar_light_16@2x.png
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmphyomnemk -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-unread.svg
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmpdc8i4nab -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-mention.svg
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmpaq7hwufl -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-tray.svg
[DEBUG] 2021-09-23 06:22:44 Backup file: /tmp/files|assets|files|linux|files|top_bar_dark_16.png to: /home/alex/.config/Hardcode-Tray/Mattermost/2021-09-23 06:22:43/files|assets|files|linux|files|top_bar_dark_16.png
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmp3wgx1tc2 -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-unread.svg
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmp_i3kucko -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-mention.svg
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmpxeukqnhp -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-tray.svg
[DEBUG] 2021-09-23 06:22:44 Backup file: /tmp/files|assets|files|linux|files|top_bar_dark_16@2x.png to: /home/alex/.config/Hardcode-Tray/Mattermost/2021-09-23 06:22:43/files|assets|files|linux|files|top_bar_dark_16@2x.png
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmpwmyv1ufh -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-unread.svg
[DEBUG] 2021-09-23 06:22:44 Executing command: rsvg-convert -f png -o /tmp/tmptszjzw7e -w 22 -h 22 /usr/share/icons/Papirus-Dark/22x22/panel/mattermost-mention.svg

@varlesh
Copy link
Collaborator

varlesh commented Sep 23, 2021

Other files not backuped
Screenshot_20210923_063615

@acarasimon96
Copy link
Contributor

acarasimon96 commented Sep 23, 2021

I still couldn't get the script to replace the mention and unread icons. I would consider this issue solved once that new bug gets fixed and no other side effects come out of that.

On logs backup only 16px and 16@2x icons

It turns out that a few typos in this comment with the modified mattermost.electron.json is what prevented the unread and mentioned tray icons from being replaced or backed up. I moved mention and unread after light or dark in the JSON, depending on the target filename, and it worked!

Here is the corrected mattermost.electron.json file
{
    "name": "Mattermost",
    "app_path": [
        "/opt/Mattermost/",
        "/usr/lib/mattermost/"
    ],
    "icons_path": [
        "/opt/Mattermost/resources/",
        "/usr/lib/mattermost/resources/"
    ],
    "binary": "app.asar",
    "script": "electron",
    "icons": {
        "tray-light": {
            "original": "assets/linux/top_bar_light_16.png",
            "theme": "mattermost-tray"
        },
        "tray-light-unread": {
            "original": "assets/linux/top_bar_light_unread_16.png",
            "theme": "mattermost-unread"
        },
        "tray-light-mention": {
            "original": "assets/linux/top_bar_light_mention_16.png",
            "theme": "mattermost-mention"
        },
        "tray-light@2x": {
            "original": "assets/linux/top_bar_light_16@2x.png",
            "theme": "mattermost-tray"
        },
        "tray-light@2x-unread": {
            "original": "assets/linux/top_bar_light_unread_16@2x.png",
            "theme": "mattermost-unread"
        },
        "tray-light@2x-mention": {
            "original": "assets/linux/top_bar_light_mention_16@2x.png",
            "theme": "mattermost-mention"
        },
        "tray-dark": {
            "original": "assets/linux/top_bar_dark_16.png",
            "theme": "mattermost-tray"
        },
        "tray-dark-unread": {
            "original": "assets/linux/top_bar_dark_unread_16.png",
            "theme": "mattermost-unread"
        },
        "tray-dark-mention": {
            "original": "assets/linux/top_bar_dark_mention_16.png",
            "theme": "mattermost-mention"
        },
        "tray-dark@2x": {
            "original": "assets/linux/top_bar_dark_16@2x.png",
            "theme": "mattermost-tray"
        },
        "tray-dark@2x-unread": {
            "original": "assets/linux/top_bar_dark_unread_16@2x.png",
            "theme": "mattermost-unread"
        },
        "tray-dark@2x-mention": {
            "original": "assets/linux/top_bar_dark_mention_16@2x.png",
            "theme": "mattermost-mention"
        }
    }
}

And below is the final result with the icons properly replaced
image

P.S. @rauldipeas, please remember to submit a new PR containing the new JSON file.

@varlesh
Copy link
Collaborator

varlesh commented Sep 23, 2021

also i'm extract patched asar and selected files - it's Papirus files 100 %
Screenshot_20210923_063810

@varlesh
Copy link
Collaborator

varlesh commented Sep 23, 2021

@acarasimon96 Congratulations, you are cool!!! 🥇
I can merge PR?

@acarasimon96
Copy link
Contributor

Sure, go ahead, but make sure you test the PR first on your system before merging. I'm glad I was able to help out. 😊

@varlesh
Copy link
Collaborator

varlesh commented Sep 23, 2021

@acarasimon96 Big thx!!! I'm also test it with other problem apps Franz #637 & Gitify #646 and merged

@varlesh
Copy link
Collaborator

varlesh commented Sep 23, 2021

P.S. @rauldipeas, please remember to submit a new PR containing the new JSON file.

I'm doing this

@rauldipeas
Copy link
Contributor Author

Thank you so much @acarasimon96 and @varlesh, this fix help-me so much!

@varlesh
Copy link
Collaborator

varlesh commented Sep 23, 2021

Franz & Gitify fixed too!

@steakscience
Copy link

I'm on Mattermost 5.0.4, and hardcode-tray doesn't detect it. Does it work for others?

@rauldipeas
Copy link
Contributor Author

image

@steakscience
Copy link

steakscience commented May 2, 2022

@rauldipeas Interesting... I do have app.asar in /usr/lib (same as this) but I don't know why it's not detecting.

It is detecting my apps just fine

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

Successfully merging a pull request may close this issue.

4 participants