links – excellent text and graphic web browser

links links-bookmarkslinks-graph

If you want make your web surfing quick or you are on slow connection, text web browser is best solution. There are a few of them out there, but one of the best is links. It can also be used as graphical web browser if you want (must be compiled with that option). What makes links browser my favorite choice? Ease of use, can run on almost all systems, all terminal emulators, easy to use with pull down menus, easy to configure, can display tables, frames in both graphics and text mode, numbered links for quick surfing, support for html 1.1 and 4.0 (but without css), background download and DNS lookup, possibility to hook up external programs for all MIME types, possibility to choose one of more programs at every opening, support for nested bookmarks, adjustable gammas, automatic aspect ratio, mouse support and, and, and…

Installation is easy, it can be found in official repositories, but if you want some special functions, you can compile and install links manually. There is a simple and good guide to do that at download site. Quickly said, just need to use:

$ ./configure --help
$ ./configure
$ make
$ make install    #with sudo if possible

There is very good online manual for help if needed here, or you can use the classic:

$ links --help
or
$ man links

 

Configuration is simply done with help of pull down menus, use or F9 for it and go to Settings menu for browser and View for html options.

Navigation is simple and fast with use of keyboard:

       ESC    menu/escape

       F9     menu

       F10    file menu

       TAB    next frame

       PGDN   page down

       Space  page down

       PGUP   page up

       b      page up

       CursorDOWN
              next link/down

       CursorUP
              prev link/up

       INS    scroll up

       ^P     scroll up

       DEL    scroll down

       ^N     scroll down

       [      scroll left

       ]      scroll right

       HOME   home

       END    end of page

       CursorRIGHT
              enter link/press button

       ENTER  enter link/press button

       CursorLEFT
              go back

       d      download link

       /      search in the page

       ?      search back in the page

       n      find next match

       N      find next match backwards

       f      zoom actual frame

       ^R     reload page

       g      go to URL

       G      edit the current URL and goto the result

       ^G     edit the current link and goto the result

       s      bookmark manager

       q      quit, close window if more windows are open

       Q      quit without asking

       =      document information

             toggle HTML source/rendered view

…and editing keys:

       CursorRIGHT
              move right

       CursorLEFT
              move left

       HOME   jump at the beginning

       ^A     jump at the beginning

       END    jump at the end

       ^E     jump at the end

       ^X     cut to clipboard

       ^B     copy to clipboard

       ^V     paste from clipboard

       ENTER  enter line

       BACKSPACE
              delete back character

       ^H     delete back character

       DEL    delete character

       ^D     delete character

       ^U     delete from beginning of the line

       ^K     delete to the end of the line or delete line (in textarea)

       ^W     auto complete line

…and the two keys that I did not find described in manual:

        z     history back  (discribed in --help)

        x     history forward

 

Some tips:

Using ssh tunnel (useful for safe connection on public wifi):

First make ssh tunnel connection to your ssh server with:

$ ssh -v -TND (socks port) user@(ip-address) -p (ssh port if not default)

…or with use of mosh (mobile shell):

$ mosh -a -p (mosh port) user@(ip-address) --ssh="ssh -v -TND (socks port) -p (ssh port if not default)"

…and then start links with option:

$ links -socks-proxy user@localhost:(socks port) -only-proxies 1

Available are also http, https and ftp proxy connecting options.

Using magnet links for downloading torrents:

Option is available in Setup / Mail and telnet menu, and for usage with transmission-cli (console version of Transmission enter:

transmission-remote --add %

…and for rtorrent first make the following script:

#!/bin/bash
watch_folder=~/.rtorrent/watch
cd $watch_folder
[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit;
echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent"

…save it, for instance as .rtorrent-magnet, give it execution permission, and place it somewhere under your $PATH, and enter:

/path to file/.rtorrent-magnet %

Similar browsers:
lynx – a text browser for the World Wide Web,
elinks – an advanced and well-established feature-rich text mode web browser,
w3m – text web browser and also pager,
surfraw – Shell Users’ Revolutionary Front Rage Against the Web (a very minimalistic command line interface to a variety of popular WWW search engines),
…and (maybe):
Weboob – web outside of browsers (cli and gui).

Happy surfing.

How to setup magnet link in Rtorrent

rtorrent

Rtorrent – ncurses torrent client is one of the most powerful rtorrent clients, based on libtorrent library. LibTorrent is a BitTorrent library written in C++ for *nix, with a focus on high performance and good code. The library differentiates itself from other implementations by transferring directly from file pages to the network stack. Because it’s running in console demand very little resources, so it also ideal for use with older computers and also used with screen. There are two versions, the stable version and git version which has added option to move finished torrents to another folder.

The configuration is very simple and it’s done by editing rtorrent.rc file, which can be found in /usr/share/doc/rtorrent/rtorrent.rc or online.

If you have git or patched version you can add ‘moving completed torrents’ with adding this lines to your rtorrent.rc file (don’t forget to change paths!):

# location where new torrent data is placed, and where you should place your
# 'complete' data before you place your *.torrent file into the watch folder
directory = /home/user/torrents/incomplete

# schedule a timer event named 'watch_directory_1':
# 1) triggers 10 seconds after rtorrent starts
# 2) triggers at 10 second intervals thereafter
# 3) Upon trigger, attempt to load (and start) new *.torrent files found in /home/user/torrents/watch/
# 4) set a variable named 'custom1' with the value "/home/user/torrents/complete"
# NOTE: if you do not want it to automatically start the torrent, change 'load_start' to 'load'
schedule = watch_directory_1,10,10,"load_start=/home/user/torrents/watch/*.torrent,d.set_custom1=/home/user/torrents/complete"

# insert a method with the alias 'checkdirs1'
# 1) returns true if the current path of the torrent data is not equal to the value of custom1
# 2) otherwise, returns false
system.method.insert=checkdirs1,simple,"not="$equal={d.get_custom1=,d.get_base_path=}""

# insert a method with the alias 'movecheck1'
# 1) returns true if all 3 commands return true ('result of checkdirs1' && 'torrent is 100% done', 'custom1 variable is set')
# 2) otherwise, returns false
system.method.insert=movecheck1,simple,"and={checkdirs1=,d.get_complete=,d.get_custom1=}"

# insert a method with the alias 'movedir1'
# (a series of commands, separated by ';') 
# 1) "set path of torrent to equal the value of custom1";
# 2) "mv -u  ";
# 3) "clear custom1", "stop the torrent","resume the torrent"
# 4) stop the torrent
# 5) start the torrent (to get the torrent to update the 'base path')
system.method.insert=movedir1,simple,"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start="

# set a key with the name 'move_hashed1' that is triggered by the hash_done event.
# 1) When hashing of a torrent completes, this custom key will be triggered.
# 2) when triggered, execute the 'movecheck1' method and check the return value.
# 3) if the 'movecheck' method returns 'true', execute the 'movedir1' method we inserted above.
# NOTE-0: *Only* data that has had their hash checked manually with ^R [^R = Control r].
# Or on a rtorrent restart[which initiates a hash check]. Will the data move; ~/torrents/incomplete => ~/torrents/complete for example.
# NOTE-1: 'branch' is an 'if' conditional statement: if(movecheck1){movedir1}
system.method.set_key=event.download.hash_done,move_hashed1,"branch={$movecheck1=,movedir1=}"

If you wish to have magnet links automatically added to your watch folder, use following script:

#!/bin/bash
watch_folder=~/.rtorrent/watch
cd $watch_folder  
[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit;
echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent"

…save it, for instance as .rtorrent-magnet, give it execution permission, and place it somewhere under your $PATH, then change settings of your browser to link it to that script. Here are some examples for different web browsers:

-Dwb

First make following script, name it .dwb-scheme, give it execution permission and save it somewhere in your $PATH:

#!/bin/bash
case ${DWB_SCHEME} in
mailto) xterm -e alpine ${DWB_URI};;
magnet) /home/boris/.rtorrent-magnet ${DWB_URI};;
ftp) filezilla ${DWB_URI};;
esac

Then change the Dwb settings in ~/.config/dwb/settings in line:

scheme-handler=/path/to/.dwb_scheme

– Links

Go to Settings/Mail and Telnet programs/Magnet program and add following line:

/path to file/.rtorrent-magnet %

– Firefox

Type about:config into the Location Bar (address bar) and press Enter.

Right-click: New > Boolean > Name: network.protocol-handler.expose.magnet > Value > false.

And next time you click a magnet link you will be asked which application to open it with. Select the .rtorrent-magnet script and you’ll be done.

Aditional links:

Some web interfaces:

WTorrent is a web interface to rtorrent programmed in php using Smarty templates and XMLRPC for PHP library.

nTorrent is a graphical user interface client to rtorrent (a cli torrent client) written in Java.

rTWi is a simple rTorrent web interface written in PHP.

Rtgui is a web based front end for rTorrent written in PHP and uses XML-RPC to communicate with the rTorrent client.

rutorrent – a web-based front-end with an interface very similar to uTorrent which supports many plugins and advanced features.

Remeber, if you want to use web based scripts you must add following line to your .rtorrent.rc file:

scgi_port = localhost:5000

Help links: Rtorrent user guide, Rtorrent manual page, ArchWiki and of course:

$ man rtorrent

Happy hunting.