2

I'm making this really nice script that is supposed to make my life a little bit easier by opening apps for me and I've ran into an issue with launching Firefox (or any similar browser really; same happens with Chromium as well).

Here's what my scripts do: I have initial script that launches a terminal window and runs my script in said window. That script is being launched through XFCE's sessions and startup (in bash, in a new xfce-terminal window) and works fine.

Now my second script looks like this:

foo=string
grep ';;' ~/sh.sh
read foo
#firefox &>/dev/null &
#disown

for (( i=0; i<${#foo}; i++ )); do
    case ${foo:$i:1} in
        0)  nohup mypaint &>/dev/null & ;;
        1)  exo-open --launch TerminalEmulator  ;;
        2)  gtk-launch firefox.desktop  ;;
        3)  ~/shsh/lutris.sh    ;;
        4)  nohup /usr/lib/chromium/chromium &>/dev/null &  ;;
        5)  nohup mypaint &>/dev/null &     ;;
        6)  nohup steam &>/dev/null &   ;;
    esac
done

sleep 5 && kill -1 $PPID

And the problem is: when I launch firefox through this script depending on the method I'm trying to use to detach firefox process from shell one of the two things happen: either firefox is being closed with terminal window or terminal window closes with tabs crashing (and addblock no longer working as well).

Here's the methods I've used so far:

  • multiple different combinations of nohup, &>/dev/null & and disown
  • gtk-launch firefox.desktop & and disown
  • (firefox &) and disown (this one works really well if you just type it in but doesn't work the same way in script)

And interestingly enough firefox does become a child of the init process but still dies, or tabs are still crashing, when terminal window is being closed through script.

So at this point it's either Firefox being a bitch or I'm missing a puzzle piece.

0

2 Answers 2

2

I think I've found a workaround, which is: xfce4-terminal --execute nohup firefox. It opens a new terminal window, executes the command, closes said window for some reason, and if the main shell gets killed by kill -1, it doesn't kill firefox -- neither does it crash tabs.

1
  • See also the comments at ChanganAuto's answer and Bac0n's answer at this link. (It may be more difficult with Gnome than with XFCE.)
    – sudodus
    Dec 1, 2021 at 14:02
0

The Firefox-esr dont crash, if you do on follow way:

Start the Firefox from terminal or by .sh script:

nohup firefox-esr --detach & disown

Close your Terminal window by hand or by kill.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .