by JonathanBeuys · 3y ago · 0 comments
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.
firefox -new-instance -P "Another Profile"
I just want to open a new window for my one user.
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.
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.
su desktopuser
firefox about:blank