| Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-03-2011, 11:20 PM
|
#1
|
|
Member
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69
Rep:
|
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?
|
|
|
|
05-03-2011, 11:30 PM
|
#2
|
|
Member
Registered: Feb 2004
Location: Milton, WA
Distribution: Fedora
Posts: 436
Rep:
|
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.
|
05-06-2011, 09:50 AM
|
#3
|
|
Member
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69
Original Poster
Rep:
|
I figured I could, Linux is sweet like that. I guess a better question then, is how would I do that?
|
|
|
|
05-06-2011, 10:27 AM
|
#4
|
|
Member
Registered: Jan 2009
Location: Boston, MA
Distribution: Arch Linux
Posts: 653
Rep: 
|
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.
|
|
|
|
05-07-2011, 04:40 PM
|
#5
|
|
Member
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69
Original Poster
Rep:
|
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.
|
|
|
|
05-15-2011, 02:18 PM
|
#6
|
|
Member
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69
Original Poster
Rep:
|
Ok, so I found out that you can control remote instance of elinks with the command 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.
|
|
|
|
05-15-2011, 08:31 PM
|
#7
|
|
Member
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69
Original Poster
Rep:
|
hmm...so the elinks -remote stopped working...I wonder why that would be? back to the drawing board?
|
|
|
|
05-15-2011, 08:39 PM
|
#8
|
|
Guru
Registered: Apr 2005
Location: /dev/null
Distribution: technixOS
Posts: 5,723
|
Quote:
Originally Posted by DetroitLibertyPenguin
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 
|
|
|
|
05-16-2011, 02:01 PM
|
#9
|
|
Member
Registered: May 2009
Location: Detroit, MI
Distribution: Debian (LXDE), Fedora (Sugar), PuppyLinux (JWM)
Posts: 69
Original Poster
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:59 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|