SVG icon in .desktop file no longer shows in Dock when app opens (gear icon instead)

I have a PPA for my app that I just updated for Ubuntu 22.04. Things have changed since 20.04, and while the app icon shows well in the Dock before opening the program, or when I search in the Activities overview. When I open the program a new gear icon appears though, instead of my icon. This was not the behavior on 22.04.

desktop-file-validate told me that I should remove the .svg extension from the name of the icon in the .desktop file, and debuild would not work without this removal.

Would anyone know what I have to change to get the icon to show properly in the Dock when the app is open?
Thanks for the help!

Here is the .desktop file:

[Desktop Entry]
Comment=ALignment of PHAges

[Desktop Action new-window]
Name=Open a new Window

From looking at the generated .deb package you are installing the icon as /usr/share/pixmaps/alpha-aligner.svg, which in my understanding of the icon-theme-spec is not a path under which a themed icon would be found (because it is not in a theme directory). I would suggest placing your icon in /usr/share/icons/hicolor/scalable/apps/ instead, which is a valid theme directory, intended for 3rd party apps and the package manager should automatically take care of updating the icon cache for that directory.

Or if you don’t want the icon to be themeable you can specify an absolute path in the Icon key.

Thanks @skeller for the tip!
It does look like it would make more sense to put it there. I’ve put it so that it installs at /usr/share/icons/hicolor/scalable/apps/alpha-aligner.svg.

This hasn’t solved the problem though, since the icon still doesn’t show in the Dock. It’s strange, since I can drag the Activities icon into the Dock and the proper icon will show. When I open the app, however, there is a new gear icon that appears!
Here are the two icons, one above the other:

I’m wondering if this couldn’t have something to do with the way I’ve structured my program with Gtk.ApplicationWindow?

Sorry, I somehow missed that you are only missing the icon when the program is running. In this case you need to make sure the window can be matched to the .desktop file. This can be done by making sure that the file name of the .desktop file matches the app id provided to gtk_application_new().

Again, thanks for the help!
I change the .desktop name to match the id. I don’t expicity call because I assume that I can pass the ID to the Gtk.Application constructor like so:

class AlphaApp(Gtk.Application):
  def __init__( lots of stuff here ):

The .desktop file is installed in the right place:

=> ls /usr/share/applications/swenson.alpha.desktop 

Yet the issue persists!

Try pressing alt+f2, enter lg, go to “Windows” click on your window title, press “Insert”, go to “Evaluator”, then run r(0).get_gtk_application_id() (or whatever r(x) corresponds to the just inserted window).

Is the result of that swenson.alpha?

Also gnome-shell delays updating its .desktop file cache by 5 seconds, so changes to that file will only apply after 5 seconds.

Oh wow… this is a useful tool!
The result is null :confused:

It also says “untracked” where the other apps have their app name. For example Firefox says “app: firefox_firefox.desktop”.

I must be missing something fundamental… mine is the only app that doesn’t know about its desktop file.

Screenshot from 2022-04-30 21-47-43

The .desktop file is found using the application-id, so if that’s null for some reason, the .desktop file won’t be found. Are the windows you are using GtkApplicationWindow and are you setting the correct GtkApplication when creating them?

That sounds like the fundamental thing I’m missing… I am using Gtk.ApplicationWindow, but I’m not setting an application when creating them. That is most certainly the problem.

Thank you so very much for your help @skeller! I could have been spinning my wheels for a while on this one.

So I now pass the Gtk.Application as the kwarg application to the Gtk.ApplicationWindow super class and all is well.

Oh boy… all is NOT well.
If I run the python script by calling the program from my development directory things actually work and I see app: swenson.alpha.desktop in the looking glass.

When I build the .deb and install it, opening alpha still suffers from the same problem :confused:

If get_gtk_application_id() is still null for that window, my guess would be a packaging issue. Maybe somehow your package does not use the most recent source or maybe python ends up finding some older version of the program on your system somehow.

You were right about that @skeller , thanks a ton for your sound advice!

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