You may tell me I'm a perfectionist, but I am struggling with the following:

I have two applications that do not come from the repository for which I have problems with the application icon. I am currently using the Debian 9 with Gnome 3.22.2 with the Moka icon theme (sorry for the missing link, I may only use two of them).

So I was successful in creating the desktop file such that the icon is taken from the correct icon directories (with appropriate size) from \usr\share\icons\Moka, but upon opening of the application a different icon is introduced in the Gnome dash and upon alt-tab. An example of the actual and the displayed icon is shown below:

Matlab Moka icon - Application icon in my favorites, desktop, etc., which is how it should be.

Displayed icon - Icon shown after opening the program and on Alt-Tab.

My problem considering the shown icon is with both its low res, and that it is not recognized as one and the same. Same happens for the the other application, but I consider one example sufficient.

I am familiar with the similar post on this forum named: "Lowres application icon on window switching (alt-tab)" but unfortunately this does not provide a solution. I also tried placing a high-res icon in /usr/share/pixmaps but this does not provide a solution. Even specifying a direct link to a high res figure in the .desktop does not change the 'alt-tab' icon.

Does anyone know how to overcome/fix this?

  • Thanks @don_crissti, I forgot to mention that I already attempted that, unfortunately without the intended result. – Steyn W. Aug 22 '17 at 12:34

The problem is that gnome-shell needs to be able to associate the window with the .desktop file. In applications that don't use the GtkApplication API (i.e. most non-GNOME applications) this is done by matching the WM_CLASS of the window with the corresponding .desktop file. So you either have to change the name of your .desktop file to match the WM_CLASS of the application windows or you have to specify a StartupWMClass key in your .desktop file that contains the WM_CLASS that should be matched to this .desktop file. You can find a window's WM_CLASS using xprop and then clicking on the window. It is the second entry in the list. Otherwise gnome-shell uses the icon specified by the window itself, which is probably the low resolution icon you are seeing.

  • Would you look at that, that was actually exactly the working solution! Thanks for that! – Steyn W. Aug 22 '17 at 12:31
  • @Sebastian, I tried fixing my .desktop file based on your answer here, but wasn't able to get it to work as it did for OP. The output of the xprop command contained the following line: WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "MATLAB R2017b". I added the following line in my custom desktop file: StartupWMClass="MATLAB R2017b", but that didn't work. I still see the grainy .gif instead my own icon. Any advice? – cbcoutinho Nov 25 '17 at 20:23
  • The .desktop format does not use quotes (except for the Exec key in some cases). Please try StartupWMClass=MATLAB R2017b instead. – Sebastian Nov 28 '17 at 3:51
  • This worked under X11, but not under wayland. (Also xprop does not seem to work under wayland). Is there an additional trick to get this to work under wayland? – myk Jan 9 '18 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.