Tuesday, April 20, 2010

Managing alternate browsers

For a while now, I've battled with the many problems of having too many tabs open in Firefox. One of them is faced when I want to view a link I saw on IRC, IM, Twitter, etc, and Firefox isn't running.

I click on the link; and wait. And wait. And wait. And finally Firefox pops up! But it's unusable because it's too busy loading 3 windows and 200 tabs. I just want to view this one link, I don't want the other 200 links to be opened!

For this use-case, I usually keep alternate browsers; Epiphany and/or Chromium. So I copy the link, open one of the browsers that won't open a bazillion tabs, and paste the link there. This is obviously somewhat annoying to do; and causes frustration when I forget that I don't have Firefox running and accidentally click on a link. *click* [wait] "huh? OH SHI-" *computer slows down to a crawl*

The final straw was when I realised that some clients don't let me right-click -> copy links. So I wrote a small script to make the right decision for me whenever I click on a link so I can stop worrying about behemoth-launching. Now I've set the script as my "default browser" so that all links are sent straight to it, and the proper action is taken.

What it does; is it checks if one of your browsers (listed in $ORDER in the script) is already open, and opens the link in that. For instance; if Firefox is already open, you're probably using it; and you want the link to open in that. If Firefox is not, but Epiphany is already open, best to open it in Epiphany; etc.

If no browsers are open; it tries to open the link in one of the lightweight "alternate" browsers that you have (listed in $SPAWN in the script).

Set the script as your default browser, and it shall feed hungry kittens. It certainly did so for me ;)

11 comments:

Pavel said...

God-sent!!! Same situation here ... thanks for sharing the script!

vivo said...

grabbed

vivo said...

only one small thing `ps | grep` is racey, try:

test $(pgrep -u ${USER} -U ${USER} "${name}") && return 0

pgrep is from sys-process/procps

Michael Croes said...

Perhaps instead of an alternate browser you could use an alternate profile for Firefox?

Nirbheek said...

@Pavel: Glad you found the script useful!
@vivo: True, it *is* racey; but I didn't want the script to need external deps. Do you have another solution which doesn't need anything outside @system?
@Cross: How will that solve the problem?

patrick said...

May I ask what's the reason behind leaving 200 tabs open constantly? Maybe you should switch to bookmarks? ;) Anyway the pages will be reloaded on every Firefox restart, and if you leave it running long, and you access some of them, they will be outdated and you have to refresh them manually...
You can also arrange your bookmarks, make menus and sub-menus, put the most important ones on a toolbar, etc.
Don't get me wrong, I don't want to tell you how to use your browser - just wondering...

Michael Croes said...

Using a second Firefox profile will allow you to start Firefox without opening the session associated with the first profile. As a result you'll get a fresh browser which loads fast, without needing a second browser variant.

Anonymous said...

What about using the TooManyTabs extension for Firefox?

p.s. Speaking of alternate browsers, "Post a Comment" didn't work in Konqueror. I started Firefox just to comment. :(

Unknown said...

Also, using a separate profile means no extensions are loaded, as they are per-profile, which probably saves you some start-up time.

Speaking of extensions, I think you ought to look over those extensions... I usually have around 200 tabs open like you, currently only 134tabs open, without that affecting my click-a-link start-up. The clicked link is loaded before everything else.

Unknown said...

great! Thanks! Very Usefully even when you don't use Twitter.

Unknown said...

Well, you can't blame firefox obviously for that, as mozilla are trying their best to satisfy everyone.

Firefox can't be fully customizable, secure, fast in page loading, fast in startup : there is always some trade-off.

However this issue is easily fixable, and previous comments suggested some ways.