Installing application icons

I’m following the GTK Tutorial example (https://developer.gnome.org/gtk3/stable/ch01s04.html#id-1.2.3.12.5) but cannot get my application icon to work.

I’ve:

  • installed my org.mydomain.myapp.desktop file in /usr/share/applications
  • added Icon=myapp to that file
  • installed myapp.png in /usr/share/icons/hicolor/48x48/apps

Those are all the instructions I could find in all resources that explain how to install desktop files and icons.

I’ve also tried specifying the .png extension in the .desktop file, or renaming the file org.mydomain.myapp.png, but none of that worked.

What am I missing?

The shell does show my app when I press the super button and start typing its name, so I assume the desktop file is picked up, but the icon is not.

Once you add an icon to an icon theme directory, you should also update the icon theme by running:

gtk-update-icon-cache /usr/share/icons/hicolor

So that the cache will be updated.

As a side note:

  • you really want to name your icon using the same name as the desktop file, minus the extension; this will make it easier to avoid namespace collisions, and will also allow you to distribute your application with Flatpak without having to manually rename the icon inside the manifest
  • the minimum size for an application icon should be 256 pixels; 48 pixels is too big for a menu, but way too small for a grid launcher like the one in GNOME Shell; this means it will either be downscaled, and look blurry, or be upscaled and look terrible
  • you should probably use an SVG icon, instead of a PNG, and install it under the scalable section of the icon theme directory
1 Like

Thanks @ebassi, that solved it!

I’m just following along with the tutorial, that’s why I have a 48x48 PNG.

The tutorial is not really on how to properly write an application using modern practices, so you should follow it up to a point.

Sadly, we don’t really have up to date best practices on developer.gnome.org; we’ll have to deal with that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.