7

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. Visual Studio Code in /usr/share/applications enter image description here

Why is that? How can I edit .desktop of vscode to set the icon?

  • I don't get why it doesn't show in ls command. But I changed the icon by opening the folder with sudo nautilus /usr/share/applications – Thidasa Pankaja Mar 3 '18 at 12:41
  • 2
    Maybe the actual name of the .desktop file is something completely different. The top-half of your ls-output is missing in the screenshot. – pomsky Mar 3 '18 at 12:48
  • 4
    To add to what pomsky said, each .desktop file has a Name property that can be different from the actual file name. In the terminal you will see the filename, but in Nautilus you will see the Name property (or possibly a translated version of it it). – devius Mar 3 '18 at 12:53
  • @devius +1 I have just wrote the answer in such manner. I hope it helps to clarify the problem. – N0rbert Mar 3 '18 at 12:55
  • 1
    Please don't post screenshots of text. The ls output should be posted as text with code formatting. – muru Mar 4 '18 at 5:56
13

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.

| improve this answer | |
  • Thanks. It was a conflict between vscode icon name and vscode icon name in numix theme. Changed the icon name from code to vscode and fixed the issue.(Of course I copied it to ~/.local/share/applications/). DIdn't use a png. – Thidasa Pankaja Mar 3 '18 at 12:55
  • But why doesn't ls doesn't list down the file ? – Thidasa Pankaja Mar 3 '18 at 12:56
  • 5
    @PankajaParanavitharana 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. – pomsky Mar 3 '18 at 13:01
7

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:

  1. if we know executable name (code in that case)

    grep -ir Exec=.*code /usr/share/applications/
    
  2. 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.

| improve this answer | |
  • But why doesn't ls doesn't list down the file name ? – Thidasa Pankaja Mar 3 '18 at 12:57
  • See my comment to your question above for that. – devius Mar 3 '18 at 12:59
  • You can try to execute first command, then you will know desktop file name. Then of course you can do ls /usr/share/applications/real-name-vs-code.desktop. – N0rbert Mar 3 '18 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.