Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

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
share|improve this answer
    
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
add comment

append with & . It denotes background application.

like

chrome &

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.