Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
@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: askubuntu.com/questions/36434/… –  Glutanimate Aug 15 '13 at 18:58
add comment

2 Answers 2

up vote 18 down vote accepted

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.

share|improve this answer
    
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. –  user79596 Jul 27 '12 at 6:16
add comment

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'.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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