Yet another solution.
Make sure you have wmctrl installed: sudo apt install wmctrl
Make a shortcut with the command: bash -c "wmctrl -a chrome ; [ "$?" == "1" ] && google-chrome"
Explanation: first we try to focus on chrome (wmctrl -vxa chrome
), next we verify if we are successful "$?" == "0" or not "$?" == "1" and if not we then launch google chrome ([ "$?" == "1" ] && google-chrome"
).
You also could make the shortcut bash -c "wmctrl -a chrome || google-chrome"
||
means that if the first command fails, execute the second.