My problem with Firefox is that a new Firefox windows can only be launched from the same environment (or only from a child process?) from which the first window has been started. Even the same user who started FF cannot launch a new window from a new shell. That constantly interferes with my workflow.
Example: Say firefox has been started from the Destop already and now I want to start a new Firefox window from a root terminal:
su desktopuser firefox
It does not work. It gives me "Firefox is already running, but is not responding.".
Why are you using root terminals in the first place? This has always been considered poor security practice. Consequently, your workflow is a very peculiar one, and while you personally might feel inconvenience, I don’t think that this frustrates many other Firefox users out there.
He's using 'su' to switch to desktopuser, that's not necessarily, and quite likely not, an account with root privileges. 'su' stands for 'switch user', it's not just to become root.
He uses the term “root terminal”, he writes “Start a root terminal (or a normal one and then ‘sudo su’)”, and he says he only has a single user. One will naturally assume the worst, and in spite of repeatedly posting here he hasn’t exactly made much sense about his workflow and needs beyond launching the browser.
Curious what use case you are looking at for over here? I don't want to make any assumptions. I'm wondering if what you are looking for might be covered by the functionality of tab containers.
He doesn't want a completely new browser instance, he wants Firefox to open another window but depending on its mood Firefox refuses to do this.
Chrome can do this just fine btw.
Running Firefox from the command line isn't an obscure thing either, clicking a link on other apps like Signal or Telegram also use this method to spawn new tabs/windows. And depending on how you executed the first instance, you run into problems with clicking links on other apps as well.
I pretty much need to open Firefox first before clicking links on other apps, because otherwise I can't run Firefox normally later without killing the process.
No. Sorry. I have a list of complaints with Firefox but this is clearly user error. I do this literally every day for a decade or more. It works fine. It particularly helps to not unnecessarily use things that can affect the env like launching a browser with su. In fact I can I think it a list of things that could go wrong with that.
Yes, sorry. This is a Firefox bug and not user error.
On my Linux system, this works with any other browser I try. It only fails with Firefox. If this is user error, it seems every other browser handles user errors much better.
- Firefox: First window is open, running `firefox URL` from the other terminal hangs for 15-20 seconds and then shows the popup "Firefox is already running, but is not responding. To use Firefox, you must first close the existing Firefox process, restart your device, or use a different profile.". No new tabs or windows are spawned.
- Chromium: First window is open, running a `chromium URL` command from the other terminal opens a new tab on the existing window.
- Microsoft Edge: First window is open, running a `microsoft-edge-stable URL` command from the other terminal opens a new tab on the existing window.
- Ladybird: First window is open, running `ladybird` in the other terminal opens a new ladybird window.
- Emacs/eww: First window is open, running `emacs --eval '(eww "example.com")'` on another terminal opens a new browser window.
- Netsurf: First window is open, running `netsurf URL` from the other terminal opens a new netsurf window.
- Dillo: First window is open, running `dillo URL` from the other terminal opens a new dillo window.
- Links/XLinks: First window is open, running `xlinks -G URL` from the other terminal opens a new links window.
You can see a clear pattern. Got any other browsers that refuse to run with a message like that? Or is this not a fault of Firefox, and something super extra that everything from other mainstream browsers to more obscure ones somehow handle for the user?
I have never had Firefox do this. I've used all 3 major OS types in the last 5 years and Firefox on all of them. New windows open, no muss no fuss.
>I pretty much need to open Firefox first before clicking links on other apps, because otherwise I can't run Firefox normally later without killing the process.
The only way I imagine this happening is if one doesn't save the browser session between launches, maybe? I've had "cold start" link opens and it just adds another tab to my existing pinned tabs/open tabs/etc.
It seems to be some magic Firefox puts somewhere (In the environment?) that prevents it to launch a new window from a fresh terminal that is not inherited from the same parent that launched the first window.
To make this work you need to set the XDG_RUNTIME_DIR environment variable to the same value it has in the environment Firefox is running in. For example:
I believe --no-remote should get around that if using a separate profile doesn't. Of course, you should ensure the distinct processes are not using the same config/cache files.
Did you try what I said? I'm pretty sure you just need to set some env vars right. (Not exactly sure which though. But some Googling should help, e.g. maybe how to setup dbus this way.)
I have very recently begun to see this bug; A workaround is that if you start a new Firefox from a shell on your desktop, then running “firefox” from a shell, even a different shell window, will work fine. I haven’t been able to find out why.
I found what I think was the problem for me: From the desktop, I was starting Firefox with the “--no-remote” option. If I remove that option, then it works. I did not use that option when starting in a terminal, but if I do, then the same problem appears.
I am probably not understand your use-case correctly but there's a `--new-window` flag on the firefox binary. You can use that to open new windows under the same profile.
You can easily try jourself. 1) Have Firefox open 2) Start a root terminal (or a normal one and then "sudo su" 3) sudo -u normaluser firefox --new-window example.com
I'm not sure what you mean. What I try to achieve is start a new firefox window (for the normal user) from a root terminal. So part of the command has to be "sudo -u normaluser" or "su -l normaluser" or something.
You have to pass those environment variables to Firefox through sudo.
sudo has a --preserve-env=list option but you must know the value for DBUS_SESSION_BUS_ADDRESS. That's usually
unix:path=/run/user/1000/bus
where 1000 is the id of the user Firefox is running for. Your root console could have no DBUS_SESSION_BUS_ADDRESS or have a different value for it.
To be 100% sure of the value, as you are root you could look into the environment of one of the running Firefox processes. Or wrap Firefox in a script that echoes that variable to a file before starting the browser.
I'd add -H to the options of sudo to make it set the home to normaluser's one.
I assumed that your DISPLAY is :1, which is what my Debian has set for me. That's another variable that you could read from the environment of Firefox.
You might have to pass/preserve other environment variables to make Firefox work.
The parent gave all information which should help you in figuring it out by yourself now. The message it, it should work with the right env vars, and you have multiple example env vars to check for (DBUS related, DISPLAY, etc) and Google for. This is your work now.
(You could also test the extreme case: Just copy all the env vars.)
Because this is not a support forum or a stack exchange. I give the idea, then all the test and debugging is for who has to actually make the code work.
Example: Say firefox has been started from the Destop already and now I want to start a new Firefox window from a root terminal:
It does not work. It gives me "Firefox is already running, but is not responding.".