Few application icons not appearing in Ubuntu Dock after upgrading to Ubuntu 17.10

After upgrading to Ubuntu 17.10, Ubuntu Dock icons of some of my apps are not appearing. They appear properly in the dash. I verified the *.desktop files for the applications in /usr/share/applications and ~/.local/share/applications.

E.g. dock icon is not displaying for "Terminator". Check out the attached image.

enter image description here

This is how the icon for the same application appears in dash search:

enter image description here

Content of /usr/share/applications/terminator.desktop:

[Desktop Entry]
Name=Terminator
Comment=Multiple terminals in one window
TryExec=terminator
Exec=terminator
Icon=terminator
Type=Application
Categories=GNOME;GTK;Utility;TerminalEmulator;System;
StartupNotify=true
X-Ubuntu-Gettext-Domain=terminator
X-Ayatana-Desktop-Shortcuts=NewWindow;
Keywords=terminal;shell;prompt;command;commandline;
[NewWindow Shortcut Group]
Name=Open a New Window
Exec=terminator
TargetEnvironment=Unity

Any pointers to debug this issue will be helpful.


Solution 1:

Try this method in an Xorg session, not sure whether it would work in a Wayland session.

  1. Launch one such application, say Terminator, whose correct icon is not seen in Ubuntu Dock.
  2. Run xprop WM_CLASS in Terminal. The cursor should turn into a crosshair.
  3. Place the crosshair over Terminator and click. You should get a WM_CLASS string for Terminator.
  4. Open Terminator's .desktop file and add the following line

    StartupWMClass=OBTAINED-VALUE
    

    In place of OBTAINED-VALUE put a value you got from step 3 without any quotes.

  5. Save the .desktop file.