0

I am trying to start a file compare application from the console by runnning bcompare ... & but this will start the application without activating it (focus).

Is there a way to start it and switch to it? I'm looking for something similar to Windows start command.

sorin
  • 9,888

2 Answers2

1

You can do it with wmctrl Install 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
lgarzo
  • 19,832
  • Thanks! Extra points if you update the command to try to install wmctrl if it does not exist ;) – sorin Mar 30 '12 at 13:19
  • 1
    Added a simple installation method if the command does not exist, but it is more of a joke, rather than a real solution. – lgarzo Mar 30 '12 at 13:52
0

append with & . It denotes background application.

like

chrome &

Web-E
  • 21,418