Linux – Firefox, two Linux machines, one X-server

firefoxlinuxputtysshxorg

I have a Linux machine I regularly log on to via ssh (putty) from Windows. I'm running VcXsrv X-server on my Windows desktop. I mainly use this to run a debugger (ddd) and firefox to access our web-based code review system. It's convenient to use the Linux firefox so I can launch it from a script. I normally launch this with "-new-tab" so as not to keep creating new windows.

Now I've got a new update Linux machine which I'm running alongside the old one for the time being. What I've noticed is some odd behaviour: when I launch a new firefox session if there's one already running on either machine, then it uses that.

What I'd like to be able to do is still launch as a new tab but only under the instance of firefox from the current machine, not an instance from a different machine that happens to be displaying on the same X-server.

I've been playing around with various flags including -no-remote, -new-instance and also defining and using specific profiles. However I've been unable to get the desired result. Either I get the behaviour I described above, or I get an error saying something like "Firefox is already running but not responding, please close it".

EDIT: I've been asked to edit this to provide some examples.

OK. In what follows I'll refer to M_OLD and M_NEW. These are separate machines running different versions of Linux with different versions of Firefox (1.5 and 19). I connect to them both via an ssh client called Putty and am forwarding X to an X server on my Windows desktop. There's only one X server involved.

Example 1:

So from my putty session to M_OLD I run:

firefox www.google.com &

and from my M_NEW putty session I run:

firefox www.imdb.com &

then I get one firefox 1.5 window with two tabs. If I do the same in reverse I get the same result but with firefox 19. In other words, as described in a comment below, the first command launches an instance of firefox the second simply tells the existing instance to open a new tab. Even if the instance is on another machine, so long as it's the same X server.

However I don't want this. I want to have separate instances for separate machines. So:

Example 2:

So from my putty session to M_OLD I run:

firefox -no-remote www.google.com &

and from my M_NEW putty session I run:

firefox -no-remote www.imdb.com &

Now I have two separate instances of firefox. However if I then run on M_NEW:

firefox -no-remote www.google.com &

I'll get

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

and even if I try

firefox -no-remote -new-instance www.google.com &

or just

firefox -new-instance www.google.com &

then I'll still get the error.

What I really want – and it may not be possible – is to have a separate instance for each machine but if a new URL is launched from that machine it opens a new tab. It seems as though I can only either have one instance with new tabs for each URL, or one instance per machine, but only one at a time.

Hopefully that's clearer.

Best Answer

Distinct Firefox instances (eg created with --no-remote) must have separate profiles.

Option 1: Create two (or more) profiles, one for each system running Firefox. Example

firefox --no-remote -CreateProfile localuser
firefox --no-remote -CreateProfile host2

Now start firefox and select a profile at startup

firefox --no-remote -P localuser

or

firefox --no-remote -P host1

Option 2: Set up dynamic solution to create a "disposable" profile on startup, eg a scrupt along the lines of:

TEMPPROFILE=$(date +%Y%m%d%H%M%S)
firefox --no-remote -CreateProfile $TEMPPROFILE 2>/tmp/.mozprofile.$TEMPPROFILE
firefox --no-remote -P $TEMPPROFILE

You may want to add steps to remove the temporary profile afterwards (The direcotry to remove can be found by parsing the output from the CreateProfile command, stored via the above command in /tmp/.mozprofile.$TEMPPROFILE

Related Question