SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-04-26 20:16:43

karthik
#! Member
Registered: 2009-01-29
Posts: 61

Clicking links in Terminator [SOLVED]

Hello,

Holding down CTRL and clicking on a URL  in Terminator causes Firefox to open up (or open a new tab) with that URL loaded.

How do I change this behaviour to load some other browser (elinks in another terminator window, say) instead of Firefox?

I find that (usually) on occasions when I'm dealing with URLs in a terminal, the last thing I want popping up is Firefox, sucking the life out of my semi-old PC.

The terminator_config man page does not have anything on this matter, and a rudimentary search on the forums for "terminator click hyperlink|URL" revealed nothing.

Last edited by karthik (2009-04-28 05:48:36)

Offline

Be excellent to each other!

#2 2009-04-26 21:01:00

Mehall
#! Die Hard
From: Scotland, Cold
Registered: 2009-01-17
Posts: 850
Website

Re: Clicking links in Terminator [SOLVED]

it's based on the default browser for your system I'm afraid, so changing it will make clicking on ANY link outside of a browser load up in the browser you set. (Obv clicking a link inside firefox will always open in Firefox wink

I forget the command I'm afraid, but it's something like "sudo update-alternatives --config x-www-browser" or something.


Ex-KDE user.
Collects old PC's (Coz he can't afford new ones =P)
Crunchbang @ Distrowatch
My Blog (updated infrequently, and on the #! Planet too.)

Offline

#3 2009-04-26 21:01:01

fhsm
#! Junkie
From: New Hampshire, USA
Registered: 2009-01-05
Posts: 445

Re: Clicking links in Terminator [SOLVED]

I think Terminator is just calling xdg-open to launch the URL.  xdg-open doesn't have much (any?) configuration available.  As such I think that to change the browser used by Terminator you'd have to change the default browser:

sudo update-alternatives --config x-www-browser

Jinx! almost to the second, with the same answer no less.

Last edited by fhsm (2009-04-26 21:02:18)

Offline

#4 2009-04-26 21:03:24

Mehall
#! Die Hard
From: Scotland, Cold
Registered: 2009-01-17
Posts: 850
Website

Re: Clicking links in Terminator [SOLVED]

Beat you by a second fhsm!! And I got the command right as a long-distance recall!!! big_smile


Ex-KDE user.
Collects old PC's (Coz he can't afford new ones =P)
Crunchbang @ Distrowatch
My Blog (updated infrequently, and on the #! Planet too.)

Offline

#5 2009-04-26 21:49:29

fhsm
#! Junkie
From: New Hampshire, USA
Registered: 2009-01-05
Posts: 445

Re: Clicking links in Terminator [SOLVED]

Mehall wrote:

Beat you by a second fhsm!! And I got the command right as a long-distance recall!!! big_smile

It is true, I spent that second making a esoteric reference to terminator's internal workings.

Offline

#6 2009-04-27 04:23:33

karthik
#! Member
Registered: 2009-01-29
Posts: 61

Re: Clicking links in Terminator [SOLVED]

Thank you, mehall, fhsm.

Trying to run update-alternatives gives:

There are 2 alternatives which provide `x-www-browser'.

  Selection    Alternative
-----------------------------------------------
 +        1    /usr/bin/dillo
*         2    /usr/bin/firefox-3.0

Press enter to keep the default[*], or type selection number: 

Neither of which suit my purpose. I want it to run

terminator --command elinks %

when a link is clicked. I could make a short script with the above command, but how do I get update-alternatives to recognize this as one of the x-www-browser alternatives?

Offline

#7 2009-04-27 05:36:10

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,486

Re: Clicking links in Terminator [SOLVED]

not sure how to make it recognize it, but I can tell you why it doesn't, elinks is a terminal program not X. Your updateing the preferred X browser so it doesn't show up. Hopefully that helps you get pointed in the right direction.


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#8 2009-04-27 15:28:00

CJ Master
New Member
Registered: 2009-04-27
Posts: 9

Re: Clicking links in Terminator [SOLVED]

I would look for a extremally lightweight X program, I'm sure there's some around here. I can't seem to remember the name of one for my life though. roll

Offline

#9 2009-04-27 15:39:17

karthik
#! Member
Registered: 2009-01-29
Posts: 61

Re: Clicking links in Terminator [SOLVED]

Dillo is the most lightweight X based browser there is- next only to "links2 -g", I guess. Nevertheless, navigating through Dillo is a real chore- I find elinks to be far more keyboard friendly and advanced.

Reading the xdg-open (which as mentioned above, is what terminator uses to open URLs) man page did not provide any answers either.

Offline

#10 2009-04-27 17:37:15

fhsm
#! Junkie
From: New Hampshire, USA
Registered: 2009-01-05
Posts: 445

Re: Clicking links in Terminator [SOLVED]

karthik wrote:

Reading the xdg-open (which as mentioned above, is what terminator uses to open URLs) man page did not provide any answers either.

I don't think xdg-open is the place to start trying to solve your problem.  It's only important because it shows that terminator really wants to launch an x app in response to a url click.  Terminator (terminatorterm.py) uses xgd-open to open URLs.  I don't think xdg-open can be configured.  So your first option is to hack xdg-open out of terminator and replace it with custom url handling.  If you really know what you are doing this may get you better results in the end, but it takes you totally off the reservation with terminator moving forward. 

The second option is to work with xdg-open's behavior.  xdg-open is going to look to see what you have set for x-www-browser and launch that with the url terminator passes.  The x-www-browser alternative is a sym links in /etc/alternatives set by update-alternatives (which is a perl script in sbin if you want look under the covers).  This has to be an x application so no matter what you do I don't think you can set elinks as your x-www-browser directly.  Instead you are going to need to get at elinks via a shell script that runs elinks in a new emulator window.  Something as simple as the following should get the job done:

#!/bin/sh
terminator --command="elinks $1"

To get xdg-open to do what you want, you need to do is register elinks/launcher script as a the x-www-browser alternative.  I've never added an alternative manual, but I can think of a couple of possibilities for getting elinks listed as the x-www-browser:
  1)You could manually set the symlink.  I don't know how update-alternatives "manages" /etc/alternatives, the script might respond poorly to having you go behind its back, but it may not. 
  2) You could try using update-alternatives --set.  Maybe you can make elinks the x-www-browser even though it's not on the list. 
  3) You can try adding it to the list.  Doing so on the cli is involved however you can use the galternatives gui for it.  If you want to try and add it from the cli you can read about it here or here (bottom of the page).

The downsides to this second sort of solution is that you'll spawn a new emulator window for each link and that your system wide default browser will now be elinks running in an emulator.

As an aside you have a non-x browser alternative (www-browser) that can be set.  Mine is elinks by default.  You can check this with sudo update-alternatives --config www-browser , note the lack of an x in front of www-browser.   This point is really academic as xdg-open isn't going to look at this option.

Bottom line: I'd see two options, hacking terminator to respond to links with something other than xdg-open or registering a shell script that runs elinks in an emulator as the systems x-www-browser.

Offline

#11 2009-04-27 19:36:06

fhsm
#! Junkie
From: New Hampshire, USA
Registered: 2009-01-05
Posts: 445

Re: Clicking links in Terminator [SOLVED]

Update: Karthik suggests a much better script below.  Please read the whole thread before attempting.
Composite tutorial: a post with clear instruction on how to combine all of these steps.


My previous post can be treated as helpful background to annotate what's about to happen.  I think I've got a solution worked out, here's what you do:

$ touch ~/bin/runelinks
$ gedit ~/bin/runelinks

Past the following in:

#!/bin/sh
terminator --command="elinks $1"

Then save and close.  Now chmod the script so xgd-open can run it:

 $ chmod +x ~/bin/runelinks 

Next manually set the symlink for x-www-browser:

$ sudo rm /etc/alternatives/x-www-browser
$ sudo ln -s $HOME/bin/runelinks /etc/alternatives/x-www-browser

You can undo this change by selecting another browser with:

$ sudo update-alternatives --config x-www-browser 

When you run that command elinks / runelinks will not show up on the list; however, you can make another selection and the symlink will overwrite correctly. 

I guess Openbox, like gnome, stores its own defaults elsewhere instead of using alternatives.  This means that most of the applications will still default to firefox or whatever you set with right click > "open with"

It would be much cooler if this opened within the same terminal window but that I think would take hacking up terminator.

Last edited by fhsm (2009-04-28 13:09:00)

Offline

#12 2009-04-28 05:47:14

karthik
#! Member
Registered: 2009-01-29
Posts: 61

Re: Clicking links in Terminator [SOLVED]

Thanks, Fhsm! I have it working now.

I modified your suggested "runelinks" script (great name, by the way!) to the following:

#!/bin/sh
if pgrep "^elinks$"; then                                                     
    elinks -remote "openURL($*, new-tab)"
else
    terminator --command="elinks $*"
fi

so I wouldn't have to spawn a new instance of Terminator each time I click on a link.
I followed your instructions to the dot regarding the x-www-browser soft link.

ln -fs ~/bin/runelinks /etc/alternatives/x-www-browser

(I had to force ln to replace the existing link.)

Since my www-browser alternative was already set to elinks, I spent all of yesterday trying to change the behaviour of xdg-open and xdg-mime to open links with www-browser- that would have been an elegant solution. Too bad that can't be done.

This is pretty fantastic- Firefox, Flash and Javascript cause all kinds of trouble on my old laptop- I'm now one step further away from bloat.

I really appreciate that you wrote in such detail explaining the problem and the workarounds. You're not cramped for patience or time, I take it. smile

Offline

#13 2009-04-28 07:30:13

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,058
Website

Re: Clicking links in Terminator [SOLVED]

^^ nice work guys! smile

Offline

#14 2009-04-28 12:08:39

fhsm
#! Junkie
From: New Hampshire, USA
Registered: 2009-01-05
Posts: 445

Re: Clicking links in Terminator [SOLVED]

karthik wrote:

Thanks, Fhsm! I have it working now.

I modified your suggested "runelinks" script (great name, by the way!) to the following:

#!/bin/sh
if pgrep "^elinks$"; then                                                     
    elinks -remote "openURL($*, new-tab)"
else
    terminator --command="elinks $*"
fi

so I wouldn't have to spawn a new instance of Terminator each time I click on a link.

Much better script.  Would you mind if I edited your suggestions back into my post above (w/ credit of course) so anyone else who finds this thread and fails to read the whole thing in detail can get the benefits of it?  Using tabs was a great idea. 

This was a problem worth solving.  Particularly once I found that openbox doesn't respect alternatives settings any more than gnome does smile.  Now with the tabs script it was time well spent.

Offline

#15 2009-04-28 12:20:28

karthik
#! Member
Registered: 2009-01-29
Posts: 61

Re: Clicking links in Terminator [SOLVED]

Would you mind if I edited your suggestions back into my post above (w/ credit of course) so anyone else who finds this thread and fails to read the whole thing in detail can get the benefits of it?

Of course not! Please go ahead. On that note, perhaps the name of this thread ought to be changed to "Choosing a custom x-www-browser alternative" or something like that? Mentioning Terminator in the title is misleading, seeing as the actual problem is with /etc/alternatives.

Offline

#16 2009-04-28 13:08:08

fhsm
#! Junkie
From: New Hampshire, USA
Registered: 2009-01-05
Posts: 445

Re: Clicking links in Terminator [SOLVED]

karthik wrote:

Would you mind if I edited your suggestions back into my post above (w/ credit of course) so anyone else who finds this thread and fails to read the whole thing in detail can get the benefits of it?

Of course not! Please go ahead. On that note, perhaps the name of this thread ought to be changed to "Choosing a custom x-www-browser alternative" or something like that? Mentioning Terminator in the title is misleading, seeing as the actual problem is with /etc/alternatives.

While that is true  I think the behavior is Terminator specific because not all terminals will use xgd-open to respond to url clicks.  Not to mention most people are going to think of the problem in terms of the terminal and not the debian subsystem.  All of that said you have the power to edit the original post and change the thread title.  Thanks again for bringing up the topic and providing the tabbing script. 

Composite tutorial a post with clear instruction on how to combine all of these steps.

Offline

#17 2014-02-19 20:08:10

srccon
Member
From: US of 'Merica
Registered: 2013-04-21
Posts: 35

Re: Clicking links in Terminator [SOLVED]

Dead Thread, I know.

Interesting little tidbit. I have Iceweasel, with all the privacy plugins, as my default browser verified with:

sudo update-alternatives --config x-www-browser

However, control-click in Terminator would always open links in chromium, used for webdev as my vanilla plugin-less browser, even though x-www-browser was set to iceweasel.

So I went into iceweasel preferences>Advanced>General and changed it to my default browser (I did not think that would matter due to x-www-browser), and that started terminator's URLs to open properly in Iceweasel. YAY!

So my question is, how does x-www-browser and the defaults set in within browsers work in CrunchBang?

Offline

#18 2014-03-18 23:36:03

Alad
Software Satan
Registered: 2014-02-20
Posts: 1,368

Re: Clicking links in Terminator [SOLVED]

x-www-browser played nice with terminator, until I got Chrome (Iceweasel was the x-www-browser default). This post suggested to additionally configure gnome-www-browser, to no avail.

I've also tried changing MIME types in ~/.local/share/applications/defaults.list, mimeapps.list, /usr/share/applications/defaults.list and mimecache.info ...

Amusingly setting the default browser in iceweasel fixed it for me too. What it did was change mimeapps.list to

~/.local/share/applications$ cat mimeapps.list
[Added Associations]
application/rdf+xml=geany.desktop;
x-scheme-handler/mailto=exo-mail-reader.desktop
application/x-extension-eml=userapp-Icedove-WRPTBX.desktop;
text/html=exo-web-browser.desktop;userapp-Iceweasel-595QCX.desktop;
x-scheme-handler/file=exo-file-manager.desktop
x-scheme-handler/trash=exo-file-manager.desktop
application/octet-stream=geany.desktop;
x-scheme-handler/http=userapp-Iceweasel-595QCX.desktop;
x-scheme-handler/https=userapp-Iceweasel-595QCX.desktop;
x-scheme-handler/ftp=userapp-Iceweasel-595QCX.desktop;
x-scheme-handler/chrome=userapp-Iceweasel-595QCX.desktop;
application/x-extension-htm=userapp-Iceweasel-595QCX.desktop;
application/x-extension-html=userapp-Iceweasel-595QCX.desktop;
application/x-extension-shtml=userapp-Iceweasel-595QCX.desktop;
application/xhtml+xml=userapp-Iceweasel-595QCX.desktop;
application/x-extension-xhtml=userapp-Iceweasel-595QCX.desktop;
application/x-extension-xht=userapp-Iceweasel-595QCX.desktop;

[Default Applications]
x-scheme-handler/mailto=userapp-Icedove-WRPTBX.desktop
application/x-extension-eml=userapp-Icedove-WRPTBX.desktop
message/rfc822=exo-web-browser.desktop
text/html=userapp-Iceweasel-595QCX.desktop
x-scheme-handler/http=userapp-Iceweasel-595QCX.desktop
x-scheme-handler/https=userapp-Iceweasel-595QCX.desktop
x-scheme-handler/ftp=userapp-Iceweasel-595QCX.desktop
x-scheme-handler/chrome=userapp-Iceweasel-595QCX.desktop
application/x-extension-htm=userapp-Iceweasel-595QCX.desktop
application/x-extension-html=userapp-Iceweasel-595QCX.desktop
application/x-extension-shtml=userapp-Iceweasel-595QCX.desktop
application/xhtml+xml=userapp-Iceweasel-595QCX.desktop
application/x-extension-xhtml=userapp-Iceweasel-595QCX.desktop
application/x-extension-xht=userapp-Iceweasel-595QCX.desktop

So what I did was:

sed -i 's/userapp-Iceweasel-595QCX.desktop/exo-www-browser.desktop/g' mimeapps.list

Now Terminator opens links with whatever browser set in exo-prefered-applications (by default it refers to "Debian Sensible Browser" which again refers to x-www-browser monkey ).

To clarify another thread, MIME types can be set per user, update-alternatives is system-wide.

Last edited by Alad (2014-04-01 18:56:39)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo