Stinkeye posted a code using wmctrl to detect whether a window is present (minimized or not). If it is present, it is brought into focus. If the window doesn't exist, the application is run:
I came across a lengthier version here, and in the context of using wmctrl, it would look something like this:
sh -c "wmctrl -a <str> || <start command>"
My question is about "grep -i "Firefox" > /dev/null": how does that work? What does "> /dev/null" do?
if wmctrl -l | grep -i "Firefox" > /dev/null
wmctrl -a firefox
A second point is that the author used "[f]irefox" instead of just "firefox" but I couldn't understand the reason for that.