present=`wmctrl -l | grep "YASSM v2.7"`
# We check with wmctrl -i if we have a window called YASSM.
if [ "$present" != "" ] ; then # If we do
wmctrl -R "YASSM V2.7" # we bring it in front
exit # and we exit the script
fi
# (...) # Otherwise we execute what's following here.

This bit of code is actually a "one-instance only" check.

If I can suggest an improvement, fabrice could replace the < exit > with an
< else > and push back the < fi > to the end, after the rest of the code. If
the first condition is satisfied, the part after the else will be skipped, and
the script will exit normally. There is no need to force the exit.

present=`wmctrl -l | grep "YASSM v2.7"`
# We check with wmctrl -i if we have a window called YASSM.
if [ "$present" != "" ] ; then # If we do
wmctrl -R "YASSM V2.7" # we bring it in front
else # <<=- Change
(...) # The rest of the code
fi

If I understand you correctly, this will prevent more than one instance of the program from running?

Hmmm...that's what the thread title implies but it's not what it does. If multiple instances are already running, the code grabs the first window with "YASSM V2.7" in the title (actually the oldest of the bunch) and moves it to the current desktop.

To prevent multiple instances I use wmctrl when starting programs from tray buttons. First wmctrl looks for any already existing program window and when it finds one it moves it to my present desktop, if it fails, i.e. if the program is not already running, the code starts the program.
Example for galculator:

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum