22

I'm having a problem with a couple of programs that have launchers in unity but then create a separate icon after launched. Is is possible for the launcher to track the windows it spawns to organize better? Or is this a bug in Unity itself?

enter image description here

It might not matter but this specific program is a mono program, and the icon spawned is listed as the panel.

Jorge Castro
  • 71,754
Andrew Redd
  • 2,157
  • @j-johan-edwards: I'm not sure what program to link to but it is KeePass2 available in the Software Center. – Andrew Redd Oct 27 '11 at 20:00
  • In some cases you can alleviate this by setting the StartupWMClass property in the desktop launcher of the application: http://askubuntu.com/questions/36434/how-can-i-remove-duplicate-icons-for-launched-java-programs-in-the-launcher – Glutanimate Aug 15 '13 at 18:58

3 Answers3

23

What's happening

Problems like this relate to Unity's application matching framework. To simplify the technical details, program windows and applications are two separate things to Ubuntu. Ubuntu needs to 'guess' which application owns a particular window. And sometimes that guess fails, and a question mark appears in the launcher.

The failure may be due to:

  1. A bug in BAMF (the application matching framework mentioned above).
  2. A faulty application description (aka '.desktop' file).
  3. The lack of any application description at all. Executables that launch windows do not inherently have this metadata.

The application shown in the question (KeePass2) suffers from a type 1 problem that has been reported to the appropriate bug tracker.

Examples of problems

The below examples are technical, aimed at programmers who want their own application displaying properly in the Ubuntu launcher.

Problem 3 – No application description

In order for an application to integrate with Unity—that is to say, be searchable in the Dash and placed in the launcher—it needs to have a desktop entry. Such entries are placed in the /usr/share/applications/, /usr/local/share/applications/, and $HOME/.local/share/applications/ (the latter two being for third party software, system-wide and user-only respectively). They end with a .desktop extension and follow this basic format:

[Desktop Entry]
Type=Application
Name=My Application's Name
Icon=/file/path/of/my/icon
Exec=/file/path/of/my/executable

This entry starts a program by calling the Exec executable. Whenever that program displays a window or dialog, Unity will notice that its executable "belongs" to this application description, and use the given Name and Icon in the launcher.

This is a barebones example. The formal specification covers many advanced features.

Problem 2 – Faulty application description

Let us assume that my_app.desktop exists in a valid application directory, but:

  • /file/path/of/my/icon does not exist in the filesystem.
  • /file/path/of/my/icon is not an image.
  • the entry uses some incorrect syntax or invalid tags.

In any of the above case, Ubuntu will be unable to properly list the application window in the launcher.

Problem 1 – A bug in BAMF

As of Ubuntu 11.10, BAMF has a number of bugs that prevents correct application matching. Common (temporary) pitfalls include:

  • The Exec path being a symbolic link rather than a regular file
  • The executable being a script that launches the main executable.

In these cases, programmers have no option but to use a workaround, such as removing the symbolic link abstraction, or linking to the executable directly. Neither of these are required by the desktop entry specification itself.

Jjed
  • 13,874
  • One more thing. You can have .desktop files for the same app both in ~/.local/share/applications/ and /usr/share/applications/. The first file overrides the second even if the icon is not specified in it. –  Jul 27 '12 at 06:16
1

The window can only be matched to the application if the WM_CLASS property has been set. To do this in X11 you use:

XSetClassHint( display, window, &class_hints );

You need to pass a pointer to a XClassHint structure with field 'res_name' and 'res_class'.

Bram
  • 2,479
  • 1
  • 29
  • 48
-1

I had a few issues with 16.04 including the greyed out icons and sometimes the touchpad would become erratic (Acer V15 nitro) also the software centre (maybe other icons too) would not open from the icon (only from a terminal command) . I found a recommendation somewhere to uninstall and reinstall the gnome software. Since I did this the whole system has been 100% stable no more greyed out icons and works perfectly. It looked scary initially when I rebooted after this change - lots of system messages on reboot- so do it at your own risk.

sudo apt-get autoremove gnome-software && sudo apt-get install gnome-software
Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
Steve
  • 1