You can do it with wmctrl
. Install it with sudo apt-get install wmctrl
.
Manual: [wmctrl
manpage]
Example:
wmctrl -a chrome
Switches to the desktop containing the chrome window, raises it, and gives focus.
So after starting your program, run wmctrl -a bcompare
.
As for your request, this is a not-so-elegant-way to check if the command is available, and if not it, try to install the package. (Consider it a bad hack, I think it should be a different question to answer this properly. For starters: it should have queried the package database.)
package="wmctrl"
required_command="wmctrl"
installed=`type -p $required_command`
if [ "$installed" == "" ]
then
sudo apt-get install "$package"
fi