I'm using Ubuntu 13.04 with GNOME 3. My goal is to create a custom launcher that will launch a specific VirtualBox virtual machine, and I'd like it to have it's own icon.

From a purely functional standpoint, I've been successful. This article (webupd8.org) gave me a command that directly launches a virtual machine. So I created a new .desktop file in ~/.local/share/applications that uses that command for the 'Exec' portion. When I click the launcher, the machine successfully launches.

My problem is with the icon behavior. I specified a custom icon in the .desktop file, and it shows up beautifully in my favorites bar. However, when I click the icon and the virtual machine starts up, the newly-opened window isn't associated with my custom launcher (i.e., my custom icon isn't "highlighted"). Instead, the window becomes associated with a newly-created VirtualBox icon.

Does anyone know if there's a way to indicate to GNOME 3 that I want to associate the new window with my custom icon? I remember having a similar issue with Matlab and specifying something called "StartupWMClass" in the .desktop file, but I don't know what I should set the value to in this case (or if that even applies for a non-Matlab launcher).

Here's my .desktop file in case anyone thinks it might prove useful:

[Desktop Entry]
Name=Windows 8
GenericName=Windows 8 Virtual Machine
Comment=Windows 8 in VirtualBox
Exec=VBoxManage startvm 'Windows 8'


  • So I've made a little bit of progress. I added a StartupWMClass=VirtualBox line to the desktop file and renamed it to virtualbox.desktop (the need to rename doesn't make sense to me, but it appears to be essential). This results in the behavior I want, but now there's no entry for the standard VirtualBox program in GNOME 3. May 25, 2013 at 16:10
  • So actually the StartupWMClass line has nothing to do with it. It seems that renaming the .desktop file is just overwriting the "standard" VirtualBox launcher. I'd like to have both, so I'm still looking for a solution May 25, 2013 at 16:29

3 Answers 3


I'm using latest GNOME 3.10 on fedora 20 and StartupWMClass=VirtualBox seems to do the trick.

Perhaps it was fixed since the time you asked the question?

Anyway, VirtualBox still has one drawback - all windows has the same WM_CLASS. So if you're running several machines they will be grouped together. I've filed a bug report for this: https://www.virtualbox.org/ticket/12534 . Hopefully we'll see it resolved soon.

  • That's great news! I've been running 3.6, and don't plan to upgrade until Ubuntu GNOME 14.04 is released. At that point, I'll try to verify that it's fixed for me too. Jan 1, 2014 at 17:56
  • I had to use VirtualBoxVM instead of VirtualBox. Jul 4, 2020 at 11:46

I have found a good workaround.

My windows.desktop launcher:

[Desktop Entry]
Name=Windows 10 VM
GenericName=Windows 10 Virtual Machine
Comment=Windows 10 in VirtualBox



My windows.sh file:


virtualbox --startvm agromov-vm &
sleep 1
xprop -id $(wmctrl -lp | grep $VM_PID | cut -d ' ' -f 1) -f WM_CLASS 8s -set WM_CLASS 'Windows'

"agromov-vm" is the virtual machine name
wmctrl is getting window id without mouse pointer


Just for the reference, the limitation mentioned by @atitoxic in his answer has already been fixed in VirtualBox >= 5.2.0 thanks to his bug report. However, VirtualBox assigns a generic value to WM_CLASS by default ("VirtualBox Machine" in the last version at the time of writing which is 6.0.14). To enable this feature, extra data GUI/DistinguishMachineWindowGroups must be set to true using VBoxManage:

VBoxManage setextradata <uuid|name> GUI/DistinguishMachineWindowGroups true

<uuid|name> is either the UUID or the name of the VM. It can also be set to global to enable the feature for all VMs globally.

After this, VirtualBox should assign a WM_CLASS value containing the UUID of the VM. You can verify it using xprop WM_CLASS.

  • Do you have a link to any documentation, or more examples of what "GUI/DistinguishMachineWindowGroups" does? I'm trying to show icons on Gnome shell when a VM is started. The icon set by --iconfile
    – Felipe
    Jun 5, 2020 at 21:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .