I compiled a short bash one-liner to focus a running application or launch it if it isn't running:
#!/bin/bash #intellilaunch.sh wmctrl -a $1 || $1 & disown exit 1
The command exits perfectly fine when run directly from the command line:
:~$ wmctrl -a firefox || firefox & disown  32505
A quick check with the system monitor shows that only firefox is running.
However, when I launch firefox via the script (
./intellilaunch.sh firefox) it spawns a persisting new process called
intellilaunch.sh firefox, which only exits after closing firefox.
What am I doing wrong?
I modified my script according to michas' suggestion:
#!/bin/bash program=$(basename $1) if ! wmctrl -a "$program"; then "$1"& fi
Not a one-liner anymore but it works perfectly fine now!