Mailinglist Archive: opensuse (769 mails)

< Previous Next >
[opensuse] Re: start firefox from script
On Tue, 17 May 2016 01:57, Istvan Gabor <suseuser04@...> wrote:
Bernhard Voelker írta:
On 05/16/2016 09:01 PM, 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 matters.

Thanks in advance,


I'm not yet 100% sure what you want to achieve, i.e. what should happen
with the previous tab(s),


I expect that when the browser is restarted, only one tab is opened with the
URL specified on the command line. I need this because I want to record flash
streams which can be played in a browser. I need only one flash stream opened
at at time or else they interfere.

but I'd look at the other options mentions
in --help output; some sound promising:

--no-remote Do not accept or send remote commands; implies
--new-instance Open new instance, not a new window in running instance.
--browser Open a browser window.
--new-window <url> Open <url> in a new window.
--new-tab <url> Open <url> in a new tab.
--private-window <url> Open <url> in a new private window.

All these options are useless in my case as I need exactly only one browser
window with only one site/tab opened at a time. Either a separarate window or a
second tab interferes (the sound from the stream) with the other one.

Maybe you even need to kill your normal browser window (running with
a different profile).

The script kills the browser. When it starts again it should open only one site
in one tab. But in my case it opens two tabs: the one was opened before closing
the browser and another one which is specified on the command line.

A few things come to mind:
1. there is a command called "killall" and it has a man-page
2. when a firefox starts with more than one tab, and you do not want
that, you have a problem with your settings.

Let's have a look at that:

Settings/Preferences dialog: in Tab "General" -> "Start"

Label "when firefox is started, open:" select "empty page"

and as "Startpage" enter "about:blank" (which is a empty page)

Then in a new tab enter "about:config" as location
(if a warning comes, select "I'll be careful")

in the "searchbar" enter "tab.url" (without the quotes)
now a line with the name "browser.newtab.url" should be shown
either double-left-click on the value-field, or right-click and
select "edit", change the value to "about:blank"

restart the browser, and it should start with just a empty page.

the "empty page" is handled special by firefox, in that it will be overwritten by the url you give firefox on the command line.

- Yamaban.
< Previous Next >