Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Links2 command-line browser and terminator + xterm with it.

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Links2 command-line browser and terminator + xterm with it.

#1 Post by Deb-fan »

Want to promote what I think is an amazing piece of software, apparently not well known, as there's not much by way of documentation on doing a lot of common and cool things with it. It's the links2 web browser, is available in stock Buster repo's, the version in Stretch/oldstable is listed as having some security issues. Fixed in Buster onwards. Only noting that for whomever. It's a great web browser which can be used in command-line or graphics mode, supports javascript to a decent extent, though not having flash and other javascript headaches in my opinion is a good thing, it's good in terms of security, speed and in keeping down system overhead too.

Haven't encoutered sites which don't work with it, surely will be some but not like keeping other browsers on-hand is difficult for the few exceptions. Other pro's as to links2, it's BLAZING fast(and uses a tiny amount of bandwidth/data), ridiculously light on memory + cpu-load. It's generally a good idea to keep a command-line browser on any OS's anyway, for times like if a person breaks X and thus no graphical gooey goodness is available to use. Anyway, really cool web browser "man links2" of course lists options which can be used. I prefer running the thing in cli-mode, in my case I'm doing wireless tethering to my Android phone and using the mobile data link for my laptop. Even on this crappy, lossy mobile link links2 blazes. On a solid connection, it'd have to be ridiculously faster.

To get more out of the thing, decided to enlist the help of a couple other what I think are awesome progs, there's so many in gnu/Nix it's insane but getting back, I remembered that the terminal emulator = terminator, allows people to do all kinds of layout magic, cut the terminal into sections, split them horizontally/vertically, resize whenever desired etc etc and save those layouts for reuse. I wanted a layout which would open 3 tabs, maximized with links2 opened on the http://www.google.com homepage. So I setup a new layout in terminator, launched my 3 tabs, in the right-hand panel of the terminator Preferences > Layout settings, a person can define a custom command to run in each of those, that of course could be anything you wanted, could be other sites than google etc. Command I used in each of them is ... I also set my home directory to be the working directory in all of them "/home/my-user-name". Also of course be sure to save your changes to a given terminator layout, there's an obvious "Save" button.

Code: Select all

links2 www.google.com -max-connections 16 -max-connections-to-host 8 ; bash
Which is what it does, when I launch terminator with my layout/profile used, launches links2 on the google.com site in those 3tabs, the stuff related to connections "man links2" allows it to use 16 connections and make 8 connections to any given host(server) increasing that makes links2 faster (default is 10/2), though don't get carried away with the number of connections to a host, 10 should be about tops imo, unless you're an azzhat.
Update note: Play around with this to find a sweet spot for yourself, in the case of cli-mode, parallel connections to a host aren't going to make all that great a difference, can-depending I guess, however in graphical it'd be different. Boosting # of connections should mean boost in speed. While messing around lowered my settings to 12/6, even in cli-mode would bump it up a bit. Only noting this ...
Couple other notes of interest, terminator works esp well with links2 because by default to open it's right-click menu/Settings, a person has to double right-click, thus it still also allows me to use links2's right click options, like "Open in new window", download link etc. Something else I found really annoying until figured it out, when terminator was running, it'd hijack the Ctrl + A (select all text)feature in any text-editors, the answer is to uncheck the box for "smart copy" in terminators Preferences > Global settings, then select all in editors works again. Someone can set font + size in terminator's settings too.

Note: That someone can drag-drop and reposition the tabs in terminator, just click and drag them where you want etc. Just like someone can do with tabs in ie: Firefox. Some other keyboard shortcuts I went with and changed in terminators settings, of course that's under the one for keybindings, I set Ctrl + Tab to switch tabs, Ctrl + Shift + Tab to go to previous tab, Ctrl + T open new tabs, Ctrl + W to close tabs, Ctrl + Q to close terminator, though Alt + F4 of course still works too.

Another really cool thing I noted about using terminator, when I open a new tab, I have a fullscreen terminal running, can use any commands, aliases etc desired, someone can even of course use all the layout changing magic terminator gives, I can split that tab(s), resize sections of it as desired. Terminator is pretty friggin awesome in my view. Something else terminator saves the config file at /home/yourusername/.config/terminator/config very interesting to look it over, you can obviously set and control many aspects of terminator in this file, without bothering doing so in it's normal settings, of course advise making-keeping backups of any config files, before editing overmuch. I had to change some of the size dimensions in that config file to get it to be sized and positioned as desired.

At this point I setup a keybind to launch it, I use/prefer the Openbox windows manager, so I chose to make the following keybind in its rc.xml file. Though of course that command example could be used in whichever other desktops/windows managers too. Here's the full thing though.

Code: Select all

    <keybind key="Alt-Right">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>Links2</name>
        </startupnotify>
        <command>terminator -l layout1 -p profile1</command>
      </action>
    </keybind>
Notes: Important part I'm trying to convey is just use the name of the layout and name of the profile you setup and wish to use with terminator, above there I named mine layout1/profile1 When I hit the Alt + Right (arrow key)that's what I get, terminator launches, with 3 tabs, each with links2 on google.com.

I've still much to learn about both terminator and links2, think they're both amazing though. :) Some nagglings noticed and possibly on the 2-do-dork list, as regards links2 in cli-mode, getting it to autofocus on google's search field(not much trouble to click on it), getting the "Open in new window" to work opening links on right-click, works in the graphical mode, as does copy/paste (considering trying a stand-alone clipboard app to see if it'll get things working more smoothly in cli-mode)and normal scrolling using touchpad or mouse. Consider these hassles not a big deal compared to all the benefits links2 in cli-mode provides.

Links2 can also open different media types (like youtube vids, mp3-4's etc) with external programs, such as a media player, I'm thinking about setting up youtube-dl + mpv or whichever other cool minimal options, there's TONS of great ones as usual with just about everything gnu/Linux. Got a somewhat good idea about how that's done, associating different media content with external programs to play them in links2, cool stuff and am a lil annoyed there isn't more info and tutes on this kickbutt command-line browser online. Hat's off to the developers and yeppers, it's still actively maintained, there is a newer version in Sid-unstable, so it's still bound to only keep getting better too. The default keyboard keys are great imo. Just takes some time and reading of the manpage on it to get using it down.

Here's a couple screenshots of these in action ( links2 + terminator)

Here

Two are of this junk using terminator + links2, the other is just it running in xterm. Link points to imgur, an image sharing website I've never used but hey, it's free and didn't require registration so hopefully works well.


Still haven't gotten around to fiddling with terminators appearance, could change those tab titles to something more meaningful, it uses gtk3 and actually don't mind the looks I've got now, you can do much more/else and differently obviously, go for it. :) My installs memory stats are none to shabby, for having a web-browser with 3 tabs, a terminal running etc. Had to brag a bit, as I'm proud of that. :) That's the output of "smem -tk", smem is a fairly kickbooty memory utility I've typed about before.

Next up, enter Xterm, think it's just another cool terminal emulator "man xterm" shows much xtermy goodness for the options people can use with the thing, in this case I setup a bash aliases in .bash_aliases (or someone could of course enter such into their .bashrc file) I advise people use that dedicated .bash_aliases file to manage bash aliases though. Getting back to it, set up an alias to launch links2, again, open it on google.com and maximized. Also a similar one to launch links2 in graphics mode the "-g" switch, for the few times I might want to use it in graphics mode. Here's the bash aliases used.

Code: Select all

alias links="xterm -maximized -fa 'Liberation Mono' -fs 14  -e links2 -max-connections 16 -max-connections-to-host 8 www.google.com &exit"
When I type that alias in terminal "links" that's what it does, launches xterm, maximized, with the Liberation Mono font, sized 14, then xterm executes the command after -e, which is clearly launching links2 just as shown with what was done with terminator. The &exit just closes the/whichever terminal I'm using for this. Also obviously someone needs xterm installed, the Liberation Mono font (hint: use fc-list to list available fonts on your Nixy OS goodness.)and links2 to use that. Otherwise yeppers, change it to fit your tastes and to launch links2 in graphical mode would just add -g above there ...


To end this sucker, stumbled on a cool script, which lets someone pick between 3 terminator layouts, could setup a bash alias for the purpose, of course those could all be customized to do whatever someone wishes. Haven't worked the kinks out but it's fairly self explanatory anyway. It's really interesting, so sharing the thing.

Code: Select all

PS3='Terminator options: '
options=("Split 1" "Split 2" "Split 3" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Split 1")
            config=config-1
            break
            ;;
        "Split 2")
            config=config-2
            break
            ;;
        "Split 3")
            config=config-3
            break
            ;;
        *)
            exit
            ;;
    esac
done

cd ~/.config/terminator
cp config config-
cp $config config
cd
terminator &
There you have it, happy nixing. :)
Last edited by Deb-fan on 2020-10-03 23:43, edited 1 time in total.
Most powerful FREE tech-support tool on the planet * HERE. *

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Links2 command-line browser and terminator + xterm with

#2 Post by Head_on_a_Stick »

Meh. Links2 is alright I suppose but for a text browser I prefer edbrowse :mrgreen:

And in all seriousness the a11y support in edbrowse is the best around.
deadbang

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: Links2 command-line browser and terminator + xterm with

#3 Post by Deb-fan »

^ As usual thank you for popping up in an original useful tute on something which took actual time, effort, thought etc. With some unrelated drivel or hogwashish suggestion as to improvement. Perhaps you can copy/paste something about this other browser from the Archwiki, you seem fairly good at that. Maybe put up a how-to about it, in I dunno ... a how to about it ? :D

Getting back to this how-to, about links2 ...

For giggles, launched 10 instances of links2 + terminator, so equiv of 30 warp-speed capable browser tabs going, check smem, PSS = under 300mbs, RSS still under 1gb-RAM. Check output of the cmds "uptime" and/or "top", yep cpu-load staying where I want, unless there's a reason 0.00 across the board.

It's not that this(links2)isn't widely known/used, would have to consider it a must have for every IT-pro or command-line commando's toolbox. Think for many such types getting links2 to do just about anything/everything is easy, they may well consider it self-explanatory, thus feel no need to put up tutes and how-to's for us mere mortals to learn all the useful things which can be done with it. Always going to be a real need for this type of software, thus why it's still getting actively developed, with new versions coming out in Sid/unstable.

Ps, sighs, may check out that other browser to Head_on, my response there was a lil harsh, though think well deserved and wanted to say a lot more and harsher, shrugs.
Last edited by Deb-fan on 2020-10-03 10:27, edited 1 time in total.
Most powerful FREE tech-support tool on the planet * HERE. *

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: Links2 command-line browser and terminator + xterm with

#4 Post by Deb-fan »

Found a solution for copy/paste using terminator + links2(cli-mode), someone can hold down the shift button, then it's fairly normal, hold left mouse (or touchpad)button, select desired text, then someone can either double right-click and choose copy in terminators menu or I changed one of it's default keybinds, which was Ctrl + Shift + C ... changed it to being just Ctrl + C to copy text. Other than this to paste, Ctrl + V (or right-click + paste) worked normally from there.

Note: Make that Ctrl + V works in external programs, not within links2, however decided to change that the default keybind in terminator for paste clipboard was Ctrl + Shift + V, changed it to Ctrl + V and now that keybind and right-click pasting works within links2 as well.

It's a tad awkward doing this on a touchpad, holding shift + left mouse button while using the touchpad to highlight but hey, it works and wouldn't be nearly as much of a pita for people using a normal mouse.

More weirdness, assoc with copying something ...

Someone may wish to copy-paste a link location while using links2 cli-mode, found a hack for it too. Right click on a given link, it'll appear at the bottom-left area of the browser, just use the Shift trick outlined above to highlight and copy the thing for pasting wherever.

Thinks links2 has mucho potential but definitely some rough edges, am working those out as I go along and think obviously it and terminator make an interesting combination. Being able to leverage terminators strengths to make up for some links2's limitations. Taken together think these two have all the makings of a blazing fast, feather light browser, which will run great even on the oldest crustiest low-spec system, on the chittiest data links to all things inbetween.
Most powerful FREE tech-support tool on the planet * HERE. *

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Links2 command-line browser and terminator + xterm with

#5 Post by Head_on_a_Stick »

So what advantages does links2 offer over lynx or w3m?

And do you have a tl;dr for the OP? Preferably written in actual English using full sentences and no text speak :mrgreen:
deadbang

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: Links2 command-line browser and terminator + xterm with

#6 Post by Deb-fan »

Am fairly sure I've tried both of those but it was so long ago, I don't remember anything about them. At that time was not at all inclined to dealing with learning or setting obscure keys to get a web browser to do anything, which is one advantage I can say links2 probably has, the default keys are extremely intuitive, backspace and left-arrow keys goes back a page, right arrow forward a page, space bar takes you a page down(as does pg-down, pg-up = up a page etc) up/down arrows jumps you up or down a link on the page and it tells you how many pages are on any particular webpg in the upper right of the browser.

Doesn't take much to get used to, a bit but definitely isn't complicated, people only need to read the man page and play with it a bit, quite a few handy and interesting things too. You hit the "=" equals key, tells you all kinds of interesting info about the webpg you're on, the server it's using, compression format, size compressed ( that's how much data you just downloaded) and it's size when uncompressed, IP's, pretty cool stuff. Click on a link to go there or hit Enter, right click a link has options, some don't work in cli-mode but work fine in its graphical mode.

So those other browsers I'm not familiar with but been using links2 (in cli-mode)extensively the last few dys and think it's awesome, when coupled with terminator anyway. I've about got it to a point where I can call it good, screenshots forth-coming and this is a place holder as I've got a nice chunk add for this tute. What was it the Terminator said in that movie peeps ??? Oh yeah ...

**** I'LL BE BACK ****
Last edited by Deb-fan on 2020-10-04 18:35, edited 5 times in total.
Most powerful FREE tech-support tool on the planet * HERE. *

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: Links2 command-line browser and terminator + xterm with

#7 Post by Deb-fan »

Going with a new post, crap that sucker above is kinda big but here goes more ...

Okay folks, welcome to this edition of more stuff you can do with links2 and terminator, at this point starting to think of this project as the linkinator or, errrr would it be better calling it the terminalink ? Anyway, moving on ...

At this point, I've got copy/paste working internally(inside links2 while in cli-mode) and externally(as in any other programs which handle copy-paste)using either Ctrl + C or terminators right-click to copy, Ctrl + V or right-click to paste wherever, much better. Didn't want to resort to having to use a stand-alone app for it ie: gpm etc.

Of course I wanted something else, wanted more ... an easier way to launch new tabs w links2 running on a homepage, I went with google.com again. What I wound up going with is creating a script in /home/myusername/.bin/termtab.sh yep, named the thing termtab.sh and made it executable with "chmod +x termtab.sh" The script has the following contents.

Code: Select all

#!/bin/bash
terminator -l layout1 -p profile1 --new-tab -e "links2  www.google.com -max-connections 12 -max-connections-to-host 6" ; bash
Remember from the OP above, where I mentioned I've named the terminator layout and profile I set up for this layout1/profile1, those are still what's being used here. Now all I need is a handy way to quickly run the script. Went with another Openbox keybind in it's rc.xml file. This puppy ...

Code: Select all

    <keybind key="W-t">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>Links2</name>
        </startupnotify>
        <command>/home/myusername/.bin/termtab.sh</command>
      </action>
    </keybind>
The W there is the Windows key, so when I hit that key + t, it runs my script, launches the linkinator if it isn't running, it'd have 3 tabs opened on google, otherwise adds a new tab to it if it is. I also deleted the former keybind, wanted my Alt + Right keys back, that key-combo could conflict with shortcuts set in other progs anyway. Again, this approach could be used with any-every other desktop or windows manager too. Really happy with this overall, its come a long way, and atm I've ended up with what I think is a pretty interesting blend of a blazing fast, ultra-light command-line web browser with a very kickbutt terminal emulator thrown into the mix too. A lot of weird and cool potential.

Introducing the LiNkinatoR!!! It's ALIVE, aLiveEeeEe ! :P

Links2 does have some really good default features too, many very useful and handy default keys set, has bookmarks, just hit the "s" key to add them or choose one to go to, hit the "g" key and up pops a dialogue where you can enter a URL you want to go to and wham, it'll take you there very fast. Integrated search on page, just hit the / key, type what you want to search for on the webpg, n to search for the next instance of what you were searching for or "N" to go to previous search. It's all covered in the man page for it and just takes a bit of playing with to check things out.

Many times when all someone wants is information, this could be awesome, if graphics "X" breaks, awesome, you can even run the thing from whichever tty's and no worries. Mentioned it also has a graphics mode which seemed pretty decent too though haven't really gotten around to messing with that. Not much left to do with it, will setup external progs in it's settings to handle things like pdf's, docs etc and am going to get around to re-themeing terminator, isn't ugly but the thing could use some bling, bling to make it more appealing to the eye.

Going to end this with some more imgur hosted screenshots ... Here ...
Most powerful FREE tech-support tool on the planet * HERE. *

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: Links2 command-line browser and terminator + xterm with

#8 Post by Deb-fan »

THIS JUST IN, THERE ARE GAWDS !!!! WOOT !

One thing I really like in a normal web browser like Firefox, thing has the ability to resize the text on the fly, just hold down Ctrl + the +(plus) keys to make text bigger, Ctrl + - (minus)smaller, Ctrl + 0 puts the text back to normal size. Had looked longingly at the keybinds related to resizing text like this in terminators defaults. Poked a bit, prodded, thought it wasn't meant to be. :(

However, THEY WORK in links2 cli-mode, I don't know what I was thinking but clearly didn't comprehend what those keybinds were. It's Ctrl + Shift + +(plus)keys to increase text size, etc to do the other things noted above. Am going to change them to be the same as they are in Firefox anyway. Though this is something else hella awesome the Linkinator can do ! :D

PS, just to be overly exacting-anal here. the keybinds for shrinking in terminator are Ctrl + -(minus) and Ctrl + O for the other ... So I've only got to change the default keybind for blowing txt up and am really pleased how this is working out. :)
Most powerful FREE tech-support tool on the planet * HERE. *

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: Links2 command-line browser and terminator + xterm with

#9 Post by Deb-fan »

Another add, though applies to more than the LinKiNatoR. :)

Also wanted to keep adding usability features to this setup, do really like the ability to highlight text, right click and search google-etc in a standard graphical web browser. So put on thinking cap and cooked something up. This also should work system-wide, select text anywhere, save(copy it to clipboard = xclip) run the script and the browser searches on google for that term.

Plus no doubt many other kickbutt tools and methods of doing similar, anyway. Xclip is just a lil clipboard utility and haven't bothered learning overmuch about it as yet.

Step 1. Install xclip ... it's available in the stock repositories. ie:

Code: Select all

sudo apt install xclip
Step 2. Need a script, I made mine in the following location, /home/myusername/.bin/search.sh yep, named the script search.sh. Here's the contents of the thing.

Code: Select all

#!/bin/sh
sh -c 'links2 "https://www.google.com/search?q=$(xclip -o)"'
Yes, make it executable "chmod +x /path/to/scriptname.sh"

Which is what it does when the script is run, launches links2, searches google for the last thing copied (Ctrl + C etc) to clipboard. Someone could use Firefox or whichever there too. Now need a way to run it ...

Step 3. Set up a bash alias (in yep, .bash_aliases) to run the script for me ...

Code: Select all

# adding an alias to search whatever was last copied to clipboard(xclip) with links2 + google.com
alias goog="/home/myusername/.bin/search.sh"
Could do similar with in a keybind to run it too but that's what above does, I pop open a terminator terminal/tab or other terminal emulator, type "goog", launches a links2 instance and does the search. Still some kinks to work out, definitely room for improvement, if I keep messing with it can find better ways to integrate it into the OS. Want to be able to just highlight some text, anywhere, pdf's, text docs etc, hit a keybind and have links2 pop up with the google search returns ... Still interesting and possibly useful. Think it complements this tute well, so there ya go. :)
Most powerful FREE tech-support tool on the planet * HERE. *

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: Links2 command-line browser and terminator + xterm with

#10 Post by Deb-fan »

Another random tip, not/can't list all the cool things this arrangement can do. Think they're both great progs, links2 + terminator, so someone puts them together, great + great = even better reasonably enough. Thanks very much to the developers and contributors of-to these open source projs. Anyway ...

One other thing I'd noted, sometimes want to do a minor adjustment to how the text is positioned in links2, still works great but might want to move it up/down a bit sometimes too. Enter terminator again, had set it so that it's scroll-bar was hidden, reconsidered and someone can easily change this in it's settings, put a scroll-bar on left/right etc.

Re-enabled, set it to having a scroll-bar visible on the right-side, good to go whenever wanting to adjust view on a webpg. Found something cool and useful, noted basic doc's were lacking for links2, tried to post some pointers, tips and interesting things related to using it, cause think links2 is an awesome cli-browser.

Ps, disabled it again, noted when you split a terminal tab up, each of them gets a scroll-bar and it's a bit ugly, so went back to sans scrollbar. UPDATE: Again, scrolling via touchpad works w/o any user intervention in Links2 v 2.20.2-1+b1, normal scrolling had always worked normally in other terminator tabs in former versions-setup, only wasn't in cli-mode browser tabs. Looks like the devs upstream fixed it for people now.

General impressions, newer versions of links2 have apparently received additional polish in other aspects too. :)
Most powerful FREE tech-support tool on the planet * HERE. *

Post Reply