PNG Image not displaying for desktop icon on Fedora 16/17 with Gnome

8,106

Solution 1

what does ~/.xsession-errors say? Does it hint on the error that a validation would give?

What does desktop-file-validate say?

It should say something like this:

sm.desktop: error: (will be fatal in the future): value "sm.png" for key "Icon" in group "Desktop Entry" is an icon name with an extension, but there should be no extension as described in the Icon Theme Specification if the value is not an absolute path

Edit: Here's what the desktop file looks like fixed:

[Desktop Entry]
Version=1.0
Name=My-App
GenericName=My Application
Comment=Test Application
Terminal=false
Icon=my-app
Type=Application
Exec=/opt/my-app/my-app
MimeType=application/x-executable;
Categories=Network;

Solution 2

The problem is the "Terminal=false" line. That seems to trigger a bug in GNOME and Unity's handling of the .desktop file. KDE is not affected by this bug.

I had a similar problem and after removing that line my icons are showing up properly.

This affects even recent desktops, at least Ubuntu 17.04 and Fedora Core 26 are still suffering from this bug.

Share:
8,106

Related videos on Youtube

Daniel
Author by

Daniel

My passions are software, mechanical, and electrical engineering.

Updated on September 18, 2022

Comments

  • Daniel
    Daniel over 1 year

    I attempted to create a desktop icon in Fedora Gnome but I only get a generic binary icon for my application. Installing Gimp or OpenOffice magically makes my icon appear.

    I used Google Chrome on Fedora as an reference for making a desktop icon using png images. Google Chrome uses 32-bit PNG files in /usr/share/icons/hicolor/#x#/apps/google-chrome.png, where #x# is the various resolutions: 16x16, 22x22, 24x24, 32x32, 48x48, 64x64, 128x128, and 256x256. The permissions on these files were all 0644 or -rw-r--r--. Google places their google-chrome.desktop file in /usr/local/share/applications/ with permission 0644.

    Attempt:

    I copied all of these conditions except the location of the .desktop file:

    • my-app.desktop file was placed in /usr/share/applications with permission 0644
    • All png files were saved as 32-bit images and properly located in /usr/share/icons/hicolor/#x#/apps with permission 0644
    • My desktop file is as follows:

    (my-app.desktop)

    [Desktop Entry]
    Version=1.0
    Name=My-App
    GenericName=My Application
    Comment=Test Application
    Terminal=false
    Icon=my-app.png
    Type=Application
    Exec=/opt/my-app/my-app
    MimeType=application/x-executable
    Categories=Network
    


    Result:

    Navigating to /usr/share/applications my my-app.desktop file looks like a plain file:
    enter image description here

    In the Gnome desktop menu, my application looks like a generic binary file:
    enter image description here

    Installing Gimp or OpenOffice will make my icon appear as intended without modification to the my-app.desktop file or the png files.

    I have tried the following different things to solve the problem:

    • Changing Icon=my-app.png to Icon=my-app in my-app.desktop
    • Saving the PNG files as 24-bit
    • Admin
      Admin almost 12 years
      Can you upload the problematic PNG file somewhere?
  • Daniel
    Daniel almost 12 years
    Thanks for the input. I wasn't able to discern if any of the information in ~/.xsession-errors was related to my problem. However running desktop-file-validation showed the error you mentioned plus 2 more errors. As mentioned in my question, I already tried removing the extention and still got the same problem. However I'll try rectifying the other two errors and let you know if that works. The other two errors were caused by a missing semicolon ; at the end of MimeType and Categories.
  • Daniel
    Daniel almost 12 years
    Just verified it to be working. Removing the image extension and adding a semicolon at the end of MimeType and Categories did the trick. I've modified your answer to include the fixed desktop file. Thanks!
  • erik
    erik almost 9 years
    My images were jpg, I had to convert them to png and remove the filename extension (no absolute path was given). But two of the apps I’ve created still don’t show their icon.
  • gcp
    gcp over 6 years
    Remove the "Terminal=false" line. This appears to be a Unity/GNOME bug.