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.".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.".I use a script in a root terminal to control a lot of my workflow. One thing is that I start browser windows from it when needed. I start them with
sudo -u desktopuser chromium example.com
Because sudo -u desktopuser firefox example.com
does not work.I thought that is relevant to the question "Why bother with Chrome".
desktopuser of course is the normal user which would also start Firefox if I did it via the Desktop gui.
Works with Chrome, but not with Firefox.
Works for me..
The task at hand is to open it in firefox with the desktop user.
firefox -new-instance -P "Another Profile"
I just want to open a new window for my one user.
I just want to launch a new browser window.
This does not work:
sudo -u normaluser firefox example.com
So I do: sudo -u normaluser chromium example.com
I thought that was relevant to the question "Why bother with Chrome".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.
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?
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.
>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.
Everyone has different workflows I suppose.
I used to get the "firefox not responding" all the time on Windows as well, though it has gotten a lot better not long ago.
sudo -u desktopuser XDG_RUNTIME_DIR=/run/user/1000 firefox --new-window sudo -u desktopuser XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0.0 firefox --new-window
If I now switch back to the VT running my desktop, a new Firefox window has opened.Maybe your root terminal has other environment variables set that break it? A different DBUS session maybe?
sudo -u desktopuser XDG_RUNTIME_DIR=/run/user/1000 firefox
Sorry for messing it up the first time I tried!Man, you solved it!!
Thanks a 1000 times!
I'm quite sure this should work, and you just need to set some env var or so.
It will refuse to start.
You cannot start FF from the Desktop and then start new windows from a shell.
Unless that shell was directly started from the desktop.
So it must have something to do with the environment or process tree.
It will refuse to start.
Do the following: sudo -EHs su, then as root sudo -EH -u {username} firefox --new-window
I'll leave to you the exercise of learning what the flags do, and implicitly why it fails in your case.
env -i DISPLAY=$DISPLAY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS firefox
this doesn't, it gives me the "Firefox is already running, but is not responding." message
env -i DISPLAY=$DISPLAY firefox
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.
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
DISPLAY=:1 \
sudo -H -u normaluser \
--preserve-env=DBUS_SESSION_BUS_ADDRESS,DISPLAY \
firefox
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.
(You could also test the extreme case: Just copy all the env vars.)
su desktopuser
firefox about:blank