Shell – How to stop a stickied application from launching new instance if already running

applicationdesktop-environmentgnomegnome-shellgnome3

I have a program that I have written in Python and added to Gnome with a desktop file. When I click the stickied icon in Gnome to launch it, it duplicates the icon on my task bar and opens a new instance. Other stickied applications just get a line under them. When you click these other applications (like Chrome or Sublime Text) and they are already running, gnome just jumps to their window instead of launching a new instance.

Is this behavior something that I need to handle in my application, or is this something that Gnome can handle for me? It is a PyQt4 application with a bash launcher if that makes a difference.

Edit- Forgot to mention that I am running Ubuntu-Gnome 16.10 with Gnome 3.20.4

Best Answer

I got this to work.

You need to add the key 'StartupWMClass' to your desktop entry.

StartupWMClass: If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint.

Protocol information here with more details here.

You can install xprop, run it and click the title bar to find out what class your application is.

Related Question