LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-03-2011, 11:20 PM   #1
DetroitLibertyPenguin
Member
 
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69

Rep: Reputation: 17
Use Whichever Browser is already running


I seem to switch which browser I am using a lot. I've never found one that works best for everything.

As such I also find myself switching default browswers a lot, because I really hate when I'm browising in one, and then click on a link in another application, like my email client or MY IM client, and then my machine feels the need to open a second (or third) browser. Not to mention this eats up my already limited memory.

Is there a way I can get the system to check and see which browser is currently running and then use that?

If there isn't something like that pre-built anywhere, is there any way I can simply check is program X Y or Z running, and perhaps use that to build some kind of script to write my www-browser on the fly?
 
Old 05-03-2011, 11:30 PM   #2
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
You can certainly write a shell script to do that and set the script as the default browser.

:wq
 
0 members found this post helpful.
Old 05-06-2011, 09:50 AM   #3
DetroitLibertyPenguin
Member
 
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69

Original Poster
Rep: Reputation: 17
I figured I could, Linux is sweet like that. I guess a better question then, is how would I do that?
 
Old 05-06-2011, 10:27 AM   #4
reed9
Member
 
Registered: Jan 2009
Location: Boston, MA
Distribution: Arch Linux
Posts: 653

Rep: Reputation: 142Reputation: 142
I'm not much on scripting, so I can't give you specifics, but most things use xdg-open to determine the default app to launch. You could replace the xdg-open script with your own script.


Probably use a case statement with ps probably, ie, a flow like
Case 1) check ps output for firefox, if found launch
Case 2) check ps output for chrome, if found launch
and so on.
And then a final case if nothing is found, launch a specified browser.

EDIT: Just to be clear, you probably don't want to replace the whole xdg-open script, just modify the section pertaining to setting the browser variable.

Last edited by reed9; 05-06-2011 at 10:31 AM.
 
Old 05-07-2011, 04:40 PM   #5
DetroitLibertyPenguin
Member
 
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69

Original Poster
Rep: Reputation: 17
Alright, I'm about halfway there!

So it appears as though xdg-open is dependent upon sensible-browser for browser selection as such I added the following to sensible-browser

Code:
    if ps ax | grep -v grep | grep iceweasel; then
	exec /usr/lib/iceweasel/firefox-bin ${URL:+"$URL"}
    elif ps ax |grep -v grep | grep epiphany; then
	exec /usr/bin/epiphany-browser ${URL:+"$URL"}
    elif ps ax | grep -v grep | grep elinks; then
	exec /usr/bin/elinks ${URL:+"$URL"}
    elif ps ax | grep -v grep | grep iceape-bin; then 
	exec iceape ${URL:+"$URL"}
This worked great when I just had the first two, epiphany and iceweasel, expect when using iceape mail it continued to open with iceape browser even though I would have assumed it would have opened with epiphany or iceweasel if either were already running. This may be an issue within Iceape? (iceape is Debian's unbranded version of Mozilla Seamonkey AKA Netscape Suite) FYI Iceape is my normal default browser

When I added elinks, it worked fine if I was in terminal and already had an instance of elinks running in a different window

i.e.
Code:
 xdg-open http://www.google.com
opened Google.com within the elinks browser, although within in a new tab of the current terminal window, instead of a new tab within the current instance of elinks as I had hoped. However if I clicked a hyperlink within another application, such as Icedove or Pidgin, nothing happened at all if elinks was already running, and iceweasel and epiphany were not.

For some reason the iceape one only worked when i wrote it the way i did and not when I wrote the whole string /usr/lib/iceape/iceape-bin

Any insight on getting it to work better with elinks, and getting iceape mail to use a different browser if its already running would be appreciated. Of course if I'm going about this all wrong, any insight on that would be appreciative as well.
 
Old 05-15-2011, 02:18 PM   #6
DetroitLibertyPenguin
Member
 
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69

Original Poster
Rep: Reputation: 17
Ok, so I found out that you can control remote instance of elinks with the command
Code:
 elinks -remote
As such I replaced
Code:
exec /usr/bin/elinks ${URL:+"URL"}
With
Code:
exec elinks -remote ${URL:+"URL"}
It does what I'd expect it to do that is opens the hyperlink from another program in a new tab within a running instance of elinks, assuming elinks is already running, however I didn't realize that it worked at first. This is because the focus was not automatically changed to the terminal window in which elinks was running. The others, do always switch, but I think we're going to after to ad some other snippet of code to get it to change focus as well.

Any clues would be greatly appreciated.
 
Old 05-15-2011, 08:31 PM   #7
DetroitLibertyPenguin
Member
 
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69

Original Poster
Rep: Reputation: 17
hmm...so the elinks -remote stopped working...I wonder why that would be? back to the drawing board?
 
Old 05-15-2011, 08:39 PM   #8
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by DetroitLibertyPenguin View Post
hmm...so the elinks -remote stopped working...I wonder why that would be? back to the drawing board?
Are you getting any errors or warnings within the terminal window? And could you explain how it exactly stopped working? May be something small
 
Old 05-16-2011, 02:01 PM   #9
DetroitLibertyPenguin
Member
 
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69

Original Poster
Rep: Reputation: 17
Nope, no error messages, just isn't doing anything.

So if I have my sensible-browser file set up like that and I click a link in another application, now the hyperlink turns colors, but when I click on the LXTERM that elinks is running in, nothing has changed.

I tried going to a new terminal and typing

$elinks -remote http://www.linuxquestions.org

and it just goes to a new prompt, with no action taken on the instance of elinks that is running, nor any messages showing in the terminal
 
  


Reply

Tags
browser, debian, default



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox browser is not responding or running azzbunni Linux - Laptop and Netbook 4 03-03-2011 06:45 AM
This has been bugging me for days.... or months.... whichever.... styl0 Slackware 10 01-11-2010 12:03 AM
Running from Python a browser fiomba Linux - Software 0 11-19-2004 01:24 PM
running movies on browser ankscorek Linux - Distributions 1 11-14-2004 12:21 AM
why we can't use whichever library... os2 Programming 6 06-09-2004 03:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 02:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration