9

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?

blade19899
  • 26,704
user254669
  • 91
  • 1
  • 1
  • 3

8 Answers8

13

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
Jack M
  • 1,310
  • 2
  • 16
  • 32
7

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 :) )

Jacob Vlijm
  • 83,767
5
  • 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
    
blade19899
  • 26,704
  • 2
    guys, the op is running his desktop file from /usr/share/applications ("I store this file to /usr/share/application"), where there is no point in making it executable. – Jacob Vlijm Mar 05 '14 at 11:11
  • @Jacob, true. Just tested that out. – blade19899 Mar 05 '14 at 12:21
  • 3
    I have tried this and also my desktop file is located in /usr/share/applications the icon still does not show up. – dabadaba Jan 24 '16 at 21:20
1

this answer helped me in my case.

There was a stray space at the end of the path line that prevented the icon from appearing.

grreeenn
  • 111
1

I run the .desktop file with gtk-launch, this fixed my issue, I don't know why but it works

0

Adding on to what others have said about finicky .desktop files. I've ran into this problem on Ubuntu 20.04 with a custom existing .desktop file that did not have an icon associated with it initially. Adding the Icon section to the .desktop file did not make the icon show. I found that doing an edit to the file that gtk-launch did not like, and then reverting that change, caused the icon to show.

David
  • 61
  • 1
  • 7
0

If your Exec path is too long, try separating that to multiple line using \

For me, Brave Browser was not working.

Here's how I fixed it,

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=New Tab - Brave
Icon=brave-browser
Exec=/opt/brave.com/brave/brave --disable-chrome-google-url-tracking-client --disable-domain-reliability \
 --disable-features=AutofillServerCommunication,TranslateUI,NetworkService,UnifiedConsent --enable-dom-distiller \
 --enable-features=NewExtensionUpdaterService,SimplifyHttpsIndicator --extensions-install-verification=enforce_strict --no-pings
StartupNotify=false
StartupWMClass=Brave-browser
X-BAMFGenerated=true
MimeType=x-scheme-handler/mailto;text/html;
Nazmul Khan
  • 131
  • 3
0

In my case, on Ubuntu 18.04 the Icon value was not read because of an extra comment at the end of the line (#...), so just delete extra space, comments and any quotes and it should work properly.