I installed Visual Studio but it doesn't show the icon of the app. So I was following this to set an icon.
When I go into /usr/share/applications I see the .desktop file of Visual Studio Code . But as I don't have access I can't edit it. So I opened terminal and tried to open it with sudo gedit. So for that first I tried to check the name with ls. But it doesn't list down the icon.
Why is that? How can I edit .desktop of vscode to set the icon?
2 Answers
Instead of editing the .desktop file located at /usr/share/applications/ (can cause many issues, will be overridden after an upgrade of the associated package) you can first copy the file and paste at ~/.local/share/applications/. Then edit the copied file using gedit, sudo is not required.
Why ls doesn't list down the file:ls lists the actual filename.desktop whereas Nautilus shows the name of the application as per the Name= field in filename.desktop. These two can be different. Here in this case Name=Visual Studio Code in the filename.desktop, but filename may be something completely different.
Usually icon name in Nautilus or other file-manager opened in /usr/share/applications/ may not be equal to name of .desktop file.
The correct way is to check .desktop file contents as follows:
if we know executable name (
codein that case)grep -ir Exec=.*code /usr/share/applications/if we know user-friendly name (Visual Studio Code)
grep -ir Name=.*Visual /usr/share/applications/
And then you can copy this file to ~/.local/share/applications/ and edit its Icon= field here.
Also you should read .desktop file specification to know how it works.
3