Problem program re-open when click icon

Hello everyone
I’ve made a Processing program and I export it as a Linux file.
My problem is that if my program is open and I re-click on the icon, the program opens a second time then a third time if I click again on the icon.
What I need is that when the program is running if I re-click on the icon the window program will focus on the “top” of all my other open program.
Is it possible ?

Thank you
Danny

I don’t know an easy way to do this. You could try to use a runtime.exec() to get the processes running on the machine each time your program opens, and if there’s already an instance of your program running kill the new instance. But you might have difficulty because if linux uses the same process names as windows all your sketches will have the same process name, making it hard to search for one. You could just kill the latest one but chances are you’ll still have problems if you are ever running another sketch or possibly another program written in java. That would be my approach maybe someone else knows a better way.

Ok Thx i will check around your idea

1 Like

A related approach to @figraham’s idea would be to use a launcher script – e.g. a shell script or python script. The shell script checks for a named process, and, if it does not exist, launches your program as a named process. Untested, but here is the method if you wish to try:

1 Like

ok
i was just wondering how to do that thanks for the precision
I’ll let you know if it works

thx
Danny

1 Like