I'm using a program called easystroke to invoke commands from mouse gestures – typically to launch an application. 'gnome-terminal', for example. If I already have a gnome-terminal window open, and I invoke the gnome-terminal gesture, I'd like to be setting focus to the already running instance, rather than spawn a new instance, which is of course what happens now. (I am actually more interested in this for my gmail chrome app shortcut, and other larger apps.)
I'm very new to ubuntu and linux in general, but I was hoping there might be a nifty command I could wrap around my launch command that would produce this behavior. (I'm imagining some kind of singleton app list keeper program that consumes my command line, checks if it's already in the list, transfers focus to the running process if it is (and if that process is still running), or else spawns a new process and then adds it to its list using the the command line as a key.)
Best Answer
I've written a small program called
jumpapp
for exactly this purpose. It lets you use one command to opens a new application the first time you run it, and to switch to the already open window any time you run it after that. As a bonus, if you have multiple windows open for the application, repeatedly running the command will cycle through all the application's windows.Under-the-hood,
jumpapp
locates application windows using two methods: 1) it gets all running pids for COMMAND and looks for windows with a matching_NET_WM_PID
, and 2) it looks for windows with aWM_CLASS
that matches COMMAND.If you want to try it out, it's easy to install from source, or you can install it from my PPA: