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.

This a specific example of a generic problem I haven't been able to find a solution for yet.

I have a program (Android Virtual Device Manager) that launches 'sub-programs' (namely emulators or virtual devices) from within itself (also can be launched from else where). I want any instances of EITHER of these programs to be grouped under the same Unity icon.

I have created a .desktop file to try and accomplish this but don't exactly know how to go about it. The desktop file is as follows:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Name=Android Virtual Device
Icon=/home/ben/.icons/android.svg
Exec=/home/ben/usr/bin/android avd
StartupWMClass=Android Virtual Device Manager

From what I understand, StartupWMClass is what I need to set to achieve this correctly. I have obtained the two class names ('Android Virtual Device Manager' and 'emulator64-arm') using xprop WM_CLASS on the repsective windows. Both work individually (the launcher icon is correctly attached to the program no matter what way it is launched), but I cannot get it to work for both.

I am assuming that I somehow need to set two values for StartupWMClass but have not been able to do it correctly (or know if it is a valid operation). I have tried, colon separated like environment variables, comma separated, quotes, etc and I cannot find any hints in the official documentation.

Any suggestions?

EDIT:

Another, more pedantic, but probably more identifiable example is with Matlab. I am running 2013a and the splash screen that initially shows and the program have completely different WM_CLASS values. This means, when I click my launcher with StartupWMClass=com-mathworks-util-PostVMInitben in it, the splash screen comes up with a different (default Unknown) Unity icon, while the rest comes up grouped under my launcher.

By using xprop WMCLASS and clicking on first the splash screen, then repeating with an active Matlab session I get the following terminal output:

ben@ben-OptiPlex-9010:~$ xprop WM_CLASS
WM_CLASS(STRING) = "MATLAB", "MATLAB"
ben@ben-OptiPlex-9010:~$ xprop WM_CLASS
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "com-mathworks-util-PostVMInit"

If I could specify something along the lines of:

StartupWMClass=com-mathworks-util-PostVMInitben&&MATLAB

That would work perfectly (as both work separately) but I have no idea of the syntax, if it even exists. I just know nothing I have tried has worked thus far.

Any help or a definitive answer either way would be great as I believe this is a pretty fundamental element of a well functioning desktop.

share|improve this question
1  
Would you be able to get some hints from Drawers? –  user25656 Jan 29 '13 at 3:18
1  
I have looked at the videos of Drawers in that link and from what they show, it simply groups the links, when you click any sub item, it is still created with its own icon in the Unity launcher which is what I'm trying to stop –  B T Apr 19 '13 at 1:19

1 Answer 1

Same problem for me with Starcraft II launched throw playonlinux. There is first a application launcher:

  • (WM_CLASS(STRING) = "Blizzard Launcher.exe", "Wine") and then the game itself:

  • (WM_CLASS(STRING) = "SC2.exe", "Wine")

I guess that wine is setting the class with the binary executable.

I had a look in bamf code (bamf_matcher.c, insert_desktop_file_class_into_table() method):

  • There is a map that make the association between a desktop file and one and only one class,
  • The key StartupWMClass is read with g_key_file_get_string() which is not designed to return a list of strings,
  • g_key_file_get_string_list() could do that but bamf developpers did not design the framework to be able to associate multiple classes to one single desktop file.

In my case I cheat by creating 2 desktop files with same keys but StartupWMClass. This is not perfect because I still have 2 Uniy icons when in the launcher but the important thing is I know why :-).

share|improve this answer
    
This looks very promising, I've asked a question to try and get confirmation from them, but still no response as of yet... –  B T May 27 '13 at 2:20
    
This isn't quite an answer. The answer is "you can't" because the Desktop File specification makes this value a single string and not a list of strings (which is why bamfdaemon uses get_string() and not get_string_list() for that value). –  dobey Jan 2 at 21:30

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.