Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Running Browser?

1 view
Skip to first unread message

Folderol

unread,
Aug 5, 2021, 6:23:31 AM8/5/21
to
Does anyone know of a way to find out if *any* browser is already running, and
if so, which one?

--
W J G

Andy Burns

unread,
Aug 5, 2021, 6:50:17 AM8/5/21
to
Folderol wrote:

> Does anyone know of a way to find out if *any* browser is already running, and
> if so, which one?

if you know a full list of potential browsers you're interested in, you
could do

ps -a | grep -E 'firefox|chromium|kmeleon|vivaldi|palemoon'

etc, but winkywankybrowser could be running and you won't notice.

Or you could look for things connecting to port 443 or port 80

netstat -nt | awk '{print $5}' | grep -E ':80|:443'

but that could include things other than a browser (such as update
processes) or miss browsers connecting to non-standard ports, or do
partial matches on e.g. port 44321

in short there's no good way ...

Andy Burns

unread,
Aug 5, 2021, 7:18:07 AM8/5/21
to

Folderol

unread,
Aug 5, 2021, 7:18:07 AM8/5/21
to
Does anyone know of a way to find out if *any* browser is already running, and
if so, which one?

--
W J G

Andrzej Adam Filip

unread,
Aug 5, 2021, 7:24:42 AM8/5/21
to
Andy Burns <use...@andyburns.uk> wrote:
> Folderol wrote:
>
>> Does anyone know of a way to find out if *any* browser is already running, and
>> if so, which one?
>
> if you know a full list of potential browsers you're interested in,
> you could do
>
> ps -a | grep -E 'firefox|chromium|kmeleon|vivaldi|palemoon'
>
> etc, but winkywankybrowser could be running and you won't notice.
> […]

On Debian you may get list of web browsers programs installed from packages.

# list of X-windows browsers
update-alternatives --list x-www-browser
# list of text mode browsers
update-alternatives --list www-browser

--
[Andrew] Andrzej A. Filip

Folderol

unread,
Aug 5, 2021, 10:14:07 AM8/5/21
to
On Thu, 05 Aug 2021 12:24:40 +0100 (BST)
Andrzej Adam Filip <an...@onet.eu> wrote:

>update-alternatives --list x-www-browser

Thanks both of you for the answers. However, I need this to work in any distro.
Otherwise it might have been usable - sort of, but that command reveals that a
couple of lightweight ones don't appear in the list.

I'll just have to think of something else. Maybe just point the users to the
index file and have them load it into a browser manually.

--
W J G

William Unruh

unread,
Aug 5, 2021, 10:25:40 AM8/5/21
to
On 2021-08-05, Folderol <gen...@musically.me.uk> wrote:
> Does anyone know of a way to find out if *any* browser is already running, and
> if so, which one?

ps auxww|grep <nameofbrowser>|grep -v grep
and cycle through all the browsers on your system.


>

Folderol

unread,
Aug 5, 2021, 1:19:15 PM8/5/21
to

William Unruh

unread,
Aug 5, 2021, 1:19:15 PM8/5/21
to

Andrzej Adam Filip

unread,
Aug 5, 2021, 1:19:15 PM8/5/21
to
Andy Burns <use...@andyburns.uk> wrote:
> Folderol wrote:
>
>> Does anyone know of a way to find out if *any* browser is already running, and
>> if so, which one?
>

Martin Gregorie

unread,
Aug 5, 2021, 1:56:14 PM8/5/21
to
On Thu, 05 Aug 2021 15:14:06 +0200, Folderol wrote:

>
> I'll just have to think of something else. Maybe just point the users to
> the index file and have them load it into a browser manually.
>
Does this program/project have a configuration file?
If so, define the browser to be used in it?.

Thats my usual approach for anything that may change from one
installation to another.

I usually assume that the configuration file will be manually edited and
so validate it fairly carefully and treat config items that don't match
the environment/runtime conditions as a fatal errors. However, depending
on what your intended users can be expected to deal with, you may want to
add an interactive configuration editor which pops up if the
configuration doesn't match the environment.


--
--
Martin | martin at
Gregorie | gregorie dot org

Martin Gregorie

unread,
Aug 5, 2021, 7:16:33 PM8/5/21
to

Gordon

unread,
Aug 5, 2021, 9:39:54 PM8/5/21
to
On 2021-08-05, Folderol <Fold...@f1.n221.z2.fidonet.fi> wrote:
> Does anyone know of a way to find out if *any* browser is already running, and
> if so, which one?
>
Is top of any use for you? top | grep firefox

Or ps -ax | grep firefox

Gordon

unread,
Aug 6, 2021, 1:16:11 AM8/6/21
to
On 2021-08-05, Folderol <Fold...@f1.n221.z2.fidonet.fi> wrote:
> Does anyone know of a way to find out if *any* browser is already running, and
> if so, which one?
>

Folderol

unread,
Aug 6, 2021, 2:23:38 AM8/6/21
to
Thanks again for the suggestions (and Gordon too).

The problem is that this will be used by people with no understanding of what
is going on, don't know what browser they have installed - just know they have
'the Internet' - and wouldn't know how to do any configuration. They do know
how to plug in a USB stick though :)

I think the best bet is to just use XDG which will open the default browser.
Thinking about it I doubt they'll have more than one browser.

P.S. In their own fields some of them are brilliant.

--
W J G

Folderol

unread,
Aug 6, 2021, 7:16:14 AM8/6/21
to

Theo

unread,
Aug 6, 2021, 10:29:19 AM8/6/21
to
Folderol <gen...@musically.me.uk> wrote:
> Thanks both of you for the answers. However, I need this to work in any
> distro. Otherwise it might have been usable - sort of, but that command
> reveals that a couple of lightweight ones don't appear in the list.
>
> I'll just have to think of something else. Maybe just point the users to the
> index file and have them load it into a browser manually.

$ xdg-open example.html

will open the file in the user's default browser, however that may be
configured.

You can find out the default via:

$ xdg-settings --list
Known properties:
default-url-scheme-handler Default handler for URL scheme
default-web-browser Default web browser
$ xdg-settings get default-web-browser
firefox.desktop

xdg-* should work on any Linux distro or desktop environment, but not for
other desktop stacks. If they're on a Mac the equivalent is:

$ open example.html

Theo

Folderol

unread,
Aug 6, 2021, 12:54:47 PM8/6/21
to
On 06 Aug 2021 15:29:16 +0100 (BST)
Theo <theom...@chiark.greenend.org.uk> wrote:

>Folderol <gen...@musically.me.uk> wrote:
>> Thanks both of you for the answers. However, I need this to work in any
>> distro. Otherwise it might have been usable - sort of, but that command
>> reveals that a couple of lightweight ones don't appear in the list.
>>
>> I'll just have to think of something else. Maybe just point the users to the
>> index file and have them load it into a browser manually.
>
>$ xdg-open example.html
>
>will open the file in the user's default browser, however that may be
>configured.

I was aware of this, but some browsers don't set the tags that XDG uses.
However, I've had a 'DOH' moment ::

The program is run from a USB stick and needs a browser only to view its
on-board HTML user guide. So it's trivially easy to use a lightweight browser
that doesn't need to be installed but can run from the same stick, then call it
directly.

I shall now go and sit in the corner wearing a dunce hat!

--
W J G

Theo

unread,
Aug 6, 2021, 1:16:23 PM8/6/21
to
Folderol <gen...@musically.me.uk> wrote:
> Thanks both of you for the answers. However, I need this to work in any
> distro. Otherwise it might have been usable - sort of, but that command
> reveals that a couple of lightweight ones don't appear in the list.
>
> I'll just have to think of something else. Maybe just point the users to the
> index file and have them load it into a browser manually.

$ xdg-open example.html

will open the file in the user's default browser, however that may be
configured.

Folderol

unread,
Aug 6, 2021, 1:16:24 PM8/6/21
to
On 06 Aug 2021 15:29:16 +0100 (BST)
Theo <theom...@chiark.greenend.org.uk> wrote:

>Folderol <gen...@musically.me.uk> wrote:
>> Thanks both of you for the answers. However, I need this to work in any
>> distro. Otherwise it might have been usable - sort of, but that command
>> reveals that a couple of lightweight ones don't appear in the list.
>>
>> I'll just have to think of something else. Maybe just point the users to the
>> index file and have them load it into a browser manually.
>
>$ xdg-open example.html
>
>will open the file in the user's default browser, however that may be
>configured.

0 new messages