On 12 Sep 2012, at 09:04, Mark Rogers wrote:
In the meantime, what annoys me is that if I have (say) Chrome open and click on a link elsewhere (eg in an email) it'll open Firefox because that's my default browser.
I'm sure it would be possible to write a script that checks to see if any browser is open, and sends the request there, only actually starting the default (Firefox) if no browsers are open.
[Actually I think this ought to be the default behaviour for a range of apps; if I have a media player open don't open a different one if I double-click a media file, etc.]
Any suggestions for where I should start?
Obvious (and therefore possibly wrong/BFI) answer is to grep the output of ps for common browser names, then run the first one found if it does or your default if it doesn't. For instance something like
#!/bin/sh b=`ps ax | grep '(firefox|chrome|opera)' | grep -v grep | head -1 | awk '{print $5}'` if [ -n $b ] exec $b "$@" else exec firefox "$@" fi
saved in one of the standard locations and set as your default browser would probably do most of the right thing. (of course, I offer no warranty on that, since I mostly just cooked it up off the top of my head)
D.