SEARCH

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

You are not logged in.

#1 2009-04-28 12:58:52

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

Make Terminator use eLinks to open ctrl+click links

Karthik asked an interesting question over in Help & Support on how to get Terminator to use eLinks instead of Firefox as the default browser when responding to ctrl+click of a hyperlink in the terminal.  The original thread provides good background and is well worth reading.  After a bit of back and forth I think we've arrived at a good solution.  The following is a compost of work by numerous authors on the original thread.

1) Create script to run eLinks as an x application

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

Paste the following in (thanks Karthik):

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

Then save and close.  Now make the script executable:

 $ chmod +x ~/bin/runelinks 

2) Manual override the x-www-alternative

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

That's it.

Explanation
Terminator uses xgd-open to respond to url clicks, more.  Xgd-open uses whatever browser is set as the x-www-alternative.  The above solution uses the Debian alternatives system but goes around the management script $ update-alternatives by manually setting the link, more and more

Openbox appears to stores default browsers independent of the alternatives system; as such, overriding x-www-alternatives has a limited scope of effect.  Firefox continues to work as the default browser in most GUI settings.  But now when ctrl+clicking a link in Terminator the url is opened in eLinks in a new tab.

Undo
This can be reversed at any time with:

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

Many thanks to Karthik, Iggykoopa, and Mehall

Last edited by fhsm (2009-06-22 03:05:23)

Offline

Help fund CrunchBang, donate to the project!

#2 2011-07-07 17:09:05

txtmsg
Member
From: los angeles
Registered: 2010-08-30
Posts: 39

Re: Make Terminator use eLinks to open ctrl+click links

reviving this thread although i'm simply trying to make firefox my default rather than chromium.

$ sudo update-alternatives --display x-www-browser
x-www-browser - auto mode
  link currently points to /home/driscoll/bin/firefox/firefox
/home/driscoll/bin/firefox/firefox - priority 150
/usr/bin/chromium-browser - priority 40
Current 'best' version is '/home/driscoll/bin/firefox/firefox'.

as you can see above, firefox is my x-www-browser but when i right-click "open link" in terminator, the link opens in chromium.

is the problem here that firefox is located in my home dir? should i make a symlink somewhere else and point to it?


{{ Eee 1005HA // Eee 1001PX // Thinkpad X131e }}
@desconcentrado

Offline

#3 2011-07-07 17:42:30

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,826
Website

Re: Make Terminator use eLinks to open ctrl+click links

Hi txtmsg,

if you are using XFCE, you could run

exo-preferred-applications

and check the Browser there.

What happens if you open

x-www-browser

and

xdg-open http://www.crunchbanglinux.org

from terminal?


Sweaty lads picking up the soap | I love the new "Ignore user" button

Offline

#4 2011-07-07 18:48:35

txtmsg
Member
From: los angeles
Registered: 2010-08-30
Posts: 39

Re: Make Terminator use eLinks to open ctrl+click links

thank you for the quick reply! we are definitely getting somewhere!

machinebacon wrote:
x-www-browser

...firefox.

machinebacon wrote:
xdg-open http://www.crunchbanglinux.org

...chromium.

i use wmii so exo-preferred-applications actually worked. do you happen to know which file or symlinks this program is modifying? i read both the man page and documentation but couldn't find it...


{{ Eee 1005HA // Eee 1001PX // Thinkpad X131e }}
@desconcentrado

Offline

#5 2011-07-07 19:02:00

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,826
Website

Re: Make Terminator use eLinks to open ctrl+click links

It creates links to  ~/.local/share/xfce4/helpers/
you find your custom-WebBrowser.desktop there
Probably you have lines there like

X-XFCE-CommandsWithParameter=/usr/bin/chromium-browser "%s"

X-XFCE-Commands=/usr/bin/chromium-browser "%s"

so you can change them to /usr/bin/firefox "s%"


Sweaty lads picking up the soap | I love the new "Ignore user" button

Offline

#6 2011-07-08 16:18:41

txtmsg
Member
From: los angeles
Registered: 2010-08-30
Posts: 39

Re: Make Terminator use eLinks to open ctrl+click links

rebooted the machine this morning and the behavior has returned. now i am perplexed.

both of these commands open firefox:

$ xdg-open http://crunchbanglinux.org
$ x-www-browser

and this looks correct:

$ cat .local/share/xfce4/helpers/custom-WebBrowser.desktop
[Desktop Entry]
NoDisplay=true
Version=1.0
Encoding=UTF-8
Type=X-XFCE-Helper
X-XFCE-Category=WebBrowser
X-XFCE-CommandsWithParameter=~/bin/firefox/firefox "%s"
Icon=firefox
Name=firefox
X-XFCE-Commands=~/bin/firefox/firefox

yet "open link" in terminator still opens chromium!


{{ Eee 1005HA // Eee 1001PX // Thinkpad X131e }}
@desconcentrado

Offline

#7 2011-07-08 20:37:55

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,826
Website

Re: Make Terminator use eLinks to open ctrl+click links

if you are using bash, you can append this line in .bashrc

export DE=xfce

Save it. Close terminator, open terminator. Terminator then calls bash, and this sets the right environment for the commands in bash. I guess smile

Last edited by machinebacon (2011-07-08 20:38:55)


Sweaty lads picking up the soap | I love the new "Ignore user" button

Offline

#8 2011-07-08 21:05:55

txtmsg
Member
From: los angeles
Registered: 2010-08-30
Posts: 39

Re: Make Terminator use eLinks to open ctrl+click links

That didn't work either, unfortunately.

I opened a question over on the Terminator launchpad:
https://answers.launchpad.net/terminato … ion/164208

An old answer suggests that Terminator attempts to open links in the following order:
* xdg-open
* GNOME helper application
* python webbrowser

I'll report back if I figure this out.

Thanks for all the help!


{{ Eee 1005HA // Eee 1001PX // Thinkpad X131e }}
@desconcentrado

Offline

#9 2011-07-08 21:36:00

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,826
Website

Re: Make Terminator use eLinks to open ctrl+click links

Yes, the problem is even more obvious if we run:

xdg-settings set default-web-browser firefox

because the output is:

xdg-settings: unknown desktop environment

and even though we set the DE=xfce, xdg doesn't accept this.

> env | grep DE
DESKTOP_SESSION=openbox
DE=xfce

roll *think think*

But something else I would like to ask you:
the section in your .dekstop file

X-XFCE-CommandsWithParameter=~/bin/firefox/firefox "%s"
Icon=firefox
Name=firefox
X-XFCE-Commands=~/bin/firefox/firefox

points to your home/user/bin/firefox/firefox - do you actually have this location? I would change the path to /usr/bin/firefox


Sweaty lads picking up the soap | I love the new "Ignore user" button

Offline

#10 2011-07-08 22:41:58

txtmsg
Member
From: los angeles
Registered: 2010-08-30
Posts: 39

Re: Make Terminator use eLinks to open ctrl+click links

.desktop points to your home/user/bin/firefox/firefox - do you actually have this location? I would change the path to /usr/bin/firefox

Yes. I do have this location but I also have a symlink at /usr/bin/firefox. This is because Firefox 5 wasn't in any repositories yet so I manually installed to ~/bin.

Check this out. For me:

$ env | grep DE
DE=xfce
DESKTOP_SESSION=wmii

$ xdg-settings get default-web-browser
firefox.desktop

For kicks, I purged chromium (which auto installs iceweasel) and, as expected, Terminator "Open Link" now opens iceweasel. (xdg-open still opens ~/bin/firefox/firefox.)

Here is some relevant output:

update-alternatives: using /usr/bin/iceweasel to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode.
Adding 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by iceweasel'

As you can see, my old symlink was moved to "firefox.real".

/usr/bin/firefox is now a shell script that tries to run firefox.real but runs iceweasel if it doesn't have permissions:

#!/bin/bash
FIREFOX="$(which $0)"
[ -x "$FIREFOX.real" ] && exec "$FIREFOX.real" "$@"

exec iceweasel "$@"

I can confirm that this script is called when I run "$ firefox" manually but it doesn't seem to get called when I click "Open Link." Even if I comment out the last line and replace it with "exec leafpad" or something similar, iceweasel still opens. This suggests that there must be something else being called first...

Hm...

PS. This blog post catalogs some common locations for default browser:
http://blog.codef00.com/2011/02/18/the- … x-debacle/


{{ Eee 1005HA // Eee 1001PX // Thinkpad X131e }}
@desconcentrado

Offline

#11 2011-07-08 22:47:40

txtmsg
Member
From: los angeles
Registered: 2010-08-30
Posts: 39

Re: Make Terminator use eLinks to open ctrl+click links

Also, dealing with the "alternatives" system, I created the following symlinks:

# ln -s /usr/bin/firefox /etc/alternatives/x-www-browser
# ln -s /usr/bin/firefox /etc/alternatives/gnome-www-browser

This didn't solve the problem either. o__O


{{ Eee 1005HA // Eee 1001PX // Thinkpad X131e }}
@desconcentrado

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.
Server: acrobat

Debian Logo