Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like improve a script of mine that uses firefox to perform tasks. I need activate a window and a tab with a specific name. For example, the window name could be Mozilla Firefox and the tab http://localhost/site.php.

I can activate windows using wmctrl -a, but this doesn't work very well because all firefox windows could have Mozilla Firefox on its name, even the windows without tabs named http://localhost/site.php.

An example of what I need is: activate the tab http://localhost/site.php at the window Mozilla Firefox. I use linux and I would like a solution for this kind of system. Probably I will use shellscript (and OS commands) and python to improve the script, so solutions with them are welcome to me.

share|improve this question
Are you aware of all the command line arguments Firefox comes with? firefox --help? – jippie May 11 '12 at 21:15
Tabs are managed internally by Firefox, they are not an OS-level like windows. wmctrl can't see tabs, you need to go through Firefox. – Gilles May 11 '12 at 23:33
@jippie, I have read the man of firefox. No solution. – GarouDan May 12 '12 at 1:30
@Gilles, maybe not, but maybe we have a solution. If I need to go to firefox to do this, how can I do this using a shellscript that calls a javascript inside firefox? – GarouDan May 12 '12 at 1:33

/path/to/firefoxbinary -new-tab http://www.google.com

is what you want. There are other useful command line arguments available:

/path/to/firefoxbinary --help

share|improve this answer
I was thinking about the -no-remote flag, which opens an entirely new firefox instance. – jippie May 12 '12 at 10:02
This will work to me if I close the previous window and create another one (using no-remote). But it isn't a good solution, the script will lose in performance and I don't know how to get the pid of the new firefox instance created. – GarouDan May 12 '12 at 13:08

Your Answer


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.