Is there a way, in bash command line, to give focus to a specific window of a running process. Assume I know the process' name, number, and anything else I need.

For instance, if I have a single instance of Firefox running, but it's minimized (or there's some other window on top of it). I need a bash command that brings up and gives focus to the Firefox window, by making it the active window.

EDIT: Using Gnome window manager (Ubuntu OS, specifically).

EDIT2: Turns out I was being to picky on my Google searches. Less strict search terms eventually led me to an answer, I'm posting it below. If anyone knows of other options, feel free to post them as well.

Thanks

link|improve this question

which window manager are you using? – jweede May 19 '10 at 14:05
@jweede: gnome window manager – Bruce Connor May 19 '10 at 14:15
feedback

2 Answers

up vote 9 down vote accepted

The wmctrl command seems to do the job. It was already installed for me, but it's available in the repositories in case anyone needs it.

wmctrl -l 

Lists currently open windows (including the gnome panels).

wmctrl -a STRING

Gives focus to a window containing STRING in its title. I'm not sure what happens if more than one window meets that condition.
In my case the command was:

wmctrl -a Firefox
link|improve this answer
1  
+1, works for me too. – Peter Jaric May 19 '10 at 15:56
1  
Nice to see someone is reading and I'm not just rambling to myself. =) – Bruce Connor May 20 '10 at 14:59
Also try xdotool. – Andres Riofrio Apr 25 at 7:04
feedback

Bizarre - it only works SOMETIMES. Tested it from terminal to bring Skype up (Works) from tray; minimise Skype and repeat same command - immediately - and it doesn't work (unless it happens to feel like it a couple of tries later). Any thoughts? (ubuntu 11.10)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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