linuxubuntuvisual-studio-codesnapcraftcompiz

VSCode icon is missing in app switcher on Ubuntu


After I installed VSCode using the the "Snap Store" on Ubuntu Mate 20.04 (Using compiz). When I do the app switching with ALT+TAB the icon of the VSCode icon is missing.

The original path for the icon is at /snap/code/43/meta/gui/com.visualstudio.code.png. enter image description here

I encountered this issue only in the app switcher for VSCode.

Other snap apps works as they should. enter image description here

The content of /var/lib/snapd/desktop/applications/code_code.desktop:

[Desktop Entry]
X-SnapInstanceName=code
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/code_code.desktop /snap/bin/code --force-user-env --no-sandbox --unity-launch %F
Icon=/snap/code/43/meta/gui/com.visualstudio.code.png
Type=Application
StartupNotify=false
StartupWMClass=Code
Categories=Utility;TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;
Actions=new-empty-window;
Keywords=vscode;

[Desktop Action new-empty-window]
Name=New Empty Window
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/code_code.desktop /snap/bin/code --force-user-env --no-sandbox --new-window %F
Icon=/snap/code/43/meta/gui/com.visualstudio.code.png

Solution

  • If you install through snap, sometimes the *.desktop file does not update correctly. You should change the Icon= path in the following file, which is the one the system uses:

    /usr/share/applications/code_code.desktop
    

    So for instance, I had to change /usr/share/applications/code_code.desktop attributes of [Desktop Entry] and [Desktop Action new-empty-window], with the correct path in Icon=, which I found in /var/lib/snapd/desktop/applications/code_code.desktop

    Icon=/snap/code/85/meta/gui/com.visualstudio.code.png instead of Icon=/snap/code/64/meta/gui/com.visualstudio.code.png

    I guess you can also do: cat /var/lib/snapd/desktop/applications/code_code.desktop > /usr/share/applications/code_code.desktop