I have recently upgraded to Ubuntu 18.04 from 16.04. Now an application of my own, which has a .desktop file in ~/.local/share/applications, is not populating the Dock with its icon — instead a generic "something is prohibited" barred icon appears — and is showing up as 'Unknown' when hovering over the icon. (In 16.04, this same application populated the Dock with its custom icon when running and showed its correct name when hovering over its Dock icon.) Also, 'Unknown' shows up in the menu next to Activities in the top menu bar. On the other hand, the custom icon appears in Nautilus, correctly associated with the .desktop file.
All this can be seen in the linked screenshot: the application is called Lexitron, its own window is frontmost, its .desktop file (with its custom icon) is shown in Nautilus, and you can see the generic 'barred' icon in the Dock with 'Unknown' showing as the application's name both there and in the top menu bar next to Activities. (My custom icon also correctly appears in the Show Applications display, but I was not able to take a screenshot of that.)
Following is the copied and pasted contents of the lexitron.desktop file itself:
[Desktop Entry] Version=0.9 Name=Lexitron Exec=/home/jason/dev/src/python3/lexicon/lexitron.py --interface graphic Icon=/home/jason/dev/src/python3/lexicon/lexitron.png Terminal=false Type=Application Categories=Application
I can put my custom icon in the Dock by pinning it there (by right-clicking on my application's icon in the Show Applications display and selecting Add to Favourites), and hovering over that icon shows the application's correct name. But that does not solve the issue either: clicking on the pinned custom icon still brings up the barred icon with its 'Unknown' tag, and it is that icon which is shown as running with a red dot next to it. (And 'Unknown' still appears as the application in the top menu bar.) All this is shown in the following linked screenshot:
Please note that:
- I have tried using a JPG file instead of a PNG file, with no change in behaviour
- There are no spaces or hidden characters at the end of the Icon specification in the .desktop file (and, in any case, the icon is used by Nautilus and the Show Applications display)
- I have tried specifying a StartupWMClass in the .desktop file as suggested in the last two postings below, but when I entered 'xprop WM_CLASS' in a terminal and clicked in my application's window, the response was 'WM_CLASS: not found'. I tried using 'StartupWMClass=Lexitron' (ie, the application's own name) but without effect. The application is a Python3/PyQt5 program.
- I have launched the application by double-clicking on the .desktop-file icon, both in its original location and after moving it to the desktop and elsewhere. The first time I do this in each location brings up an 'Untrusted launcher application' dialog and I choose 'Trust and Launch'. This makes no difference to the behaviour described above: there is still a generic icon in the dock and the application is still called 'Unknown' in the dock and the top menu.
I have researched this problem in the following posts from Ask Ubuntu (most of them rather old, and amongst others which did not seem relevant):
- 18.04 custom icon from .desktop file not populating in dock
- How can I add custom '.desktop' application launchers to Ubuntu Dock?
- Third party application Icon not displaying in dock for Ubuntu 17.10
- Duplicate application icons in Ubuntu dock upon launch
- What does the StartupWMClass field of a .desktop file represent?
However, doing everything suggested in them has not resolved the problem. Also, none of them, as far as I can tell, addresses the 'Unknown' application name issue which I have raised.
I have come to the provisional conclusion that it is nothing about my .desktop file that is causing the problem. I have tried everything suggested by @Sayen in the comments below, and I have also run
desktop-file-validate on my .desktop file, which finds no problems with it.
I have even, far more drastically, temporarily usurped an existing, fully functional, .desktop file, in this case, that for Shotwell, at /usr/share/applications/shotwell.desktop. After creating a backup, I changed the Exec line (only) in shotwell.desktop to point to my application. Using that edited .desktop file, either by double-clicking on it directly or by clicking on the Shotwell icon in the display produced by the Show Applications icon, my application runs normally but the launcher shows the generic barred icon with the 'Unknown' name, as described and shown above.
So it seems to me that there is something about my Python3/PyQt5 application itself which does not agree with the mechanism behind the launcher. I will investigate further and update this post if I have anything to report.