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. – Garrett Warnell May 25 '13 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 – Garrett Warnell May 25 '13 at 16:29

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. – Garrett Warnell Jan 1 '14 at 17:56

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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