Mailinglist Archive: opensuse (769 mails)

< Previous Next >
Re: [opensuse] start firefox from script
"Carlos E. R."írta:
On 2016-05-16 21:01, Istvan Gabor wrote:

I would like to start firefox browser from bash script. I made this script:

#! /bin/bash

ffpid=`pidof firefox`

echo "firefox PID is: $ffpid"

if test $ffexit == 0
then `kill -9 $ffpid`

sleep 5

firefox -P list &


What I want is to check if firefox is running, if it's runing stop it and
start it again with specific profile with specific URL.
This works with the above script but the problem is if I run the script at
least two times, the second time firefox opens with two tabs,
with the same content in both tabs. How can I force it to open only on tab
with the URL in the command line specified?
In firefox preferences I've set General/Startup: When firefox start: Show a
blank page. I use an old firefox version (24.8.1 ESR,
the last ESR that doesn't have australis uinterface), I don't know if it


You have to verify that the second time it really obtains the PID of the
running firefox. Then you have to verify that it is killed, and wait
till it does die (not five seconds), and if it doesn't, abort with message.

Suggest kill, then loop till PID is not found. Also suggest do not use
kill 9, but a normal kill.

Thanks Carlos.

I expreminted a little bit with starting and stopping firefox in the command

I start firefox:


Then I stop it using kill:

ps -e|grep firefox
13404 pts/8 00:00:00 firefox

kill 13404

Then I start it again:


Now firefox opens the site that was opened before killing firefox (restores
previous session).

If I shutdown firefox from within firefox (close button, or file/quit) and
start it again it opens with blank tab does not restore previous session.

It seems that killing firefox using its pid is not equal to shutting it down.
In the former case it reopens the site which was killed. How could I close
firefox from a script/command line normally as if it would be closed as by a
normal shutdown?



To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >