Custom icon for .desktop file not appearing

I intend to change from Windows 7 to Ubuntu.

There are some icons on the desktop I would like to use on Ubuntu.

I converted these icons to *.png 64*64 pixel and put in /home/user/icons

Then I use the terminal:

sudo gedit

to:

[desktop entry]
Name=Account
Exec=/home/user/jameica/jameica.sh
Icon=/home/user/icons/ico_account.png
Terminal=false
Type=application

I store this file to /usr/share/application with the name account.desktop

The desktop entry is created, but not with the desired icon.

What is wrong?


Solution 1:

As of July 2018, there seem to be some bugs in Unity in how it reads .desktop files. Specifically, the path provided for the Icon field cannot be wrapped in quotes. Even if the path contains spaces, it must not be wrapped in quotes.

On the other hand, it's worth mentioning here that the path provided for the Exec field must be wrapped in quotes if it contains spaces. If it doesn't contain spaces, the quotes can be left off. This inconsistency in behavior is horribly confusing and should really be considered a bug.

Thus, the following is a valid .desktop:

[Desktop Entry]
Name=Firefox Developer Edition
Comment=The developer edition of Firefox Quantum.
Exec="/home/jack/Applications/Firefox Developer Edition/firefox"
Icon=/home/jack/Applications/Firefox Developer Edition/browser/chrome/icons/default/default32.png
Terminal=false
Type=Application

The following will run, but not display the icon:

[Desktop Entry]
Name=Firefox Developer Edition
Comment=The developer edition of Firefox Quantum.
Exec="/home/jack/Applications/Firefox Developer Edition/firefox"
Icon="/home/jack/Applications/Firefox Developer Edition/browser/chrome/icons/default/default32.png"
Terminal=false
Type=Application

And the following won't even run:

[Desktop Entry]
Name=Firefox Developer Edition
Comment=The developer edition of Firefox Quantum.
Exec=/home/jack/Applications/Firefox Developer Edition/firefox
Icon=/home/jack/Applications/Firefox Developer Edition/browser/chrome/icons/default/default32.png
Terminal=false
Type=Application

Solution 2:

There are a few things wrong with your desktop file:

[Desktop Entry]: both should be with a capital (instead of [desktop entry]),

same with: Type=Application (instead of Type=application)

With these errors the desktop file will neither work, nor show it's icon, however:

Note that sometimes, even with a correct desktop file, you do not see the icon on the file itself (especially with .png icons), but it will show (with icon) and work well in the launcher.

Unless you use the desktop file from the desktop, it does not need to be executable. Since you run it from from /usr/share/applications, there is no point in making it executable. Once you corrected the errors above, it should show and work correctly in the launcher. (given the fact that the script works :) )

Solution 3:

  • Enable it to run as an executable (right-click > properties) :

run as executable

Or

  • Enable it to run as an executable (command-line) :

    sudo chmod +x /usr/share/application/account.desktop