[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash: finding if mozilla is running



On -5360-Sat, Jul 26, 2003 at 02:21:52PM +0200, Sebastian Kapfer <sebastian_kapfer@web.de> spake thus,
> On Sat, 26 Jul 2003 11:30:06 +0200, David selby wrote:
> 
> > I need to know if mozilla is running, if not I need to call it first ...
> > seemed simple
> 
> Yeah. That's why I use Galeon. I never understood Mozilla's remote
> control. :-) Of course, Galeon has other advantages, too...
> 
> > Whatever I grep for, grep will find in ps ax as grep xxxxxx, a bit
> > frustrating !!
> 
> use "ps -C mozilla-bin", no grep
> 
> -- 
> Best Regards,   |   Hi! I'm a .signature virus. Copy me into
>  Sebastian      |   your ~/.signature to help me spread!
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

I use a small shell script to get the behavior I'm used to from
similar browsers in Windows where if the app is running I get a new
tab, but if it's not it launches to the specified URL. Here it is,
hopefully it's some help to someone (I hate it when it's already
running and something tries to run it again to display a URL and I get
the profile selection dialog!):

I know there's probably a better (e.g. shorter) way to achieve this
result, but I'm not a bash scripting master yet.

#!/bin/bash

# Count the number of instances of 'mozilla-bin' in my process list.
MOZ=`ps waux | grep mozilla-bin | wc -l`

# If there seems to be more than one instance (moz always seems to
# start more than one thread when it's running)...
if [ "$MOZ" -gt 1 ]; then
# Cause the running Mozilla to open a new tab to the URL...
	`mozilla -remote "openurl($1,new-tab)"`
else
# Or just open a new Mozilla to the URL...
	`mozilla "$1" &`
fi

Cheers.

-- 
Aaron Bieber
-
Graphic Design // Web Design
http://www.core-dev.com/
aaron@core-dev.com



Reply to: