+
AMDG
Goodman Coat of Arms

Goodman's Oak

Miscellaneous Thoughts, Projects, and Ruminations on Life, the Universe, and Everything

Browser Wars: The Best Web Browser

Donald P. Goodman III 26 Dec 1200 (30 Dec 2016)

The World Wide Web has become by far the most frequently used part of the Internet, and the tool with which one uses it is often, therefore, the subject of intense debate. Of course, for years we were stuck with the horrors of Internet Explorer 6, only quite recently improved by later versions, with the only practical alternative being an out-of-date, incompatible Netscape or a text-only browser like lynx. Text-only browsers (w3m is probably the best at the moment) still have their moments; but most of the time, we want to use a graphical browser, and our options in this case still seem quite limited, though much less so than they used to be. There are now three main competitors:

Firefox, the great IE-killer, is the behemoth that finally broke IE's stranglehood on the graphical browser world. Chrome is Google's answer, and it has been taking market share from Firefox recently. And finally, there is Internet Explorer. (Opera is still an option, but it's not a huge player; and functionally, it's pretty similar to the others.)

The problem with these options is that they are all primarily mouse-driven, and the amount of time I spend with a browser makes a keyboard-driven interface preferable. They also tend to be clunky, as they tend to absorb a lot of different functions into themselves. All, for example, support tabbing, although tabbing is really something that the window manager ought to be handling.

What is the fundamental task of the browser? Rendering web pages. Not playing videos; not playing audio; not browsing files; not multiplexing instances of itself in a single window. Just rendering web pages. The rest can be done by other things; indeed, it can be done by other things such that the appearance is identical to that of the monolithic browser. But the Unix way is to do one thing and do it well; that one thing, for a browser, is to display web pages.

So I wanted a browser that respected the Unix way of doing things:

And I found it!

uzbl

Uzbl (pronounced "usable") is a Webkit-powered browser which meets all of these requirements and more. Its webpage is even subtitled "web interface tools which adhere to the unix philosophy," which is exactly what I want.

Uzbl provides mostly single- or double-key bindings for controlling itself; e.g., "w" opens a new window, "ZZ" closes the window, "b" goes back one page in the history. Numbers will pop up beside links when you hit "fl" or "Fl"; you then follow the link by typing the appropriate number. The lowercase version will follow the link in the same window; the uppercase version will follow it in a new window. "c" will clone the window (open the same web page, but in a different window). And so on. The keybindings are incredibly configurable, and you can add or change any of these.

It can be "tabbed" like other browsers, but it doesn't absorb that functionality into itself; you can use any number of window multiplexers. My personal preference is tabbed, from the suckless project ("software that sucks less"). It's a very bare-bones implementation of a window multiplexer that just stores different windows in the same single window and otherwise stays out of your way---which is exactly what I want. It does one thing and does it well. (Unfortunately, the documentation is nearly nonexistent; but this article will show you what you need to know.)

The setup requires a bit of scripting to make it work acceptably. Here are the things you'll need to do or obtain:

  1. Uzbl itself.
  2. tabbed.
  3. A few minor modifications to the uzbl config file.
  4. A short script to work with your multiplexing.
  5. If you use newsbeuter, you probably want to amend your config file. We'll cover that, as well.

I'll assume that you know how to install software on your system, so we'll skip steps 1 and 2, and head straight to step 3.

Set up Your uzbl Config

Uzbl puts its configuration in the $HOME/.config/uzbl/ directory, where you'll find two files: config and style.css. You can ignore the CSS file for now (you'll probably want to make some modifications to that eventually, as well; but for now, we can set it aside). There's also a third file we'll need to play with, which could be located in a number of places: download.sh, in order to set our download directory. You may have to search for this; by default, it's located in /usr/share/uzbl/examples/data/scripts/. Finally, we need to produce an environmental variable, UZBL_UTIL_DIR.

I like to have all my configs and scripts in one place, so I change the default locations for these bits to my config directory under my home directory. The default locations for these things are in /usr/share/uzbl/. So the first thing, for my setup, that needs to happen is to reproduce the scripts in my config directory:

$> cd ~/.config/uzbl/
$> mkdir scripts/
$> cp -R /usr/share/uzbl/examples/data/scripts/* ./scripts/

Then we need to make sure that uzbl knows where to look for the scripts; that is, not in the default directory. If you open ~/.config/uzbl/config, you'll find a few variables you'll need to modify; find the lines starting with the variable names and change them to the following:

set prefix      = /home/username/.config/uzbl
set data_home   = /home/username/.config/uzbl
set scripts_dir = /home/username/.config/uzbl/scripts
set cache_home  = /home/username/.config/uzbl
set config_home = /home/username/.config/uzbl

Then, you'll need to export an environmental variable to tell uzbl where to find its utility scripts. How to do this exactly will depend on your shell. For bash, the following will work:

export UZBL_UTIL_DIR=/home/username/.config/uzbl/scripts/util

You should probably put this in your .bashrc so that you don't need to do it again.

Next, you need to tell the utility script uzbl-dir.sh to look in the correct directories. Go to ~/.config/uzbl/scripts/util/uzbl-dir.sh and change the directories to reflect the appropriate directories under your user's config directory. This should be self-explanatory.

Finally, you'll need to write a script to tell uzbl to open in a tabbed window. Here's one way for it to look:

#!/bin/sh
# +AMDG

if [ "$#" -ne 1 ]; then
	echo "error:  requires URL of the site to open"
	exit
fi

if [ $(ps aux | pgrep tabbed) ]; then
	echo "tabbed is already running..."
else
	tabbed -d > /tmp/tabbed.xid
fi
uzbl-browser -s `cat /tmp/tabbed.xid` $1 2> /dev/null &

You'll call this script when you start uzbl, not uzbl itself; it takes one argument, the URL you want to open. It takes care of all the logistics of calling tabbed if tabbed isn't already running, and then loading uzbl into the tabbed window.

Then you'll need to let uzbl know to open new windows within the tabbed window, as well. Go to ~/.config/uzbl/config and find the line that starts like the one below, and change it to the following:

@on_event   NEW_WINDOW     sh 'uzbl-browser -s `cat /tmp/tabbed.xid` ${1:+-u "$1"}' %r

Lastly, to make it work with newsbeuter, go to your newsbeuter config file and find the browser line, then make it read the following:

browser "new_uzbl_tab.sh %u"

Now you're ready to go! Let's look at a few ways to use this system.

Using the Setup

First, let's open up a window. Run the following:

new_uzbl_tab.sh http://www.uzbl.org

This will start tabbed, then load your uzbl instance into the tabbed window. You will see "uzbl-core" printed in a gray bar on the top of the window. Now, try opening a new window; hit "w" (which will open a new window to your home page) or "c" ("clone," which will open a new window with the same URL loaded). If all is set up right, this will cause a new uzbl window to open within the tabbed window.

To switch between windows, hit "CTRL-SHFT-l" (to switch to the right) or "CTRL-SHIFT-h" (to switch to the left). To close a window, you can hit "ZZ" (which will close the uzbl instance, which in turn closes that window) or "CTRL-q" (which closes the tabbed window). These two methods have the same effect.

Hit "fl", and the links on the page will light up with numbers in the top left corners. Enter the numbers to follow those links in the same window. If you want to follow them in a new window, hit "Fl" instead. This new window will also open within the tabbed window.

By default, I found the numbers difficult to read, so I changed their color scheme. You can do this in the style.css file in your ~/.config/uzbl/ directory. The two classes you're looking for are uzbl_link_hints and uzbl_link_hints.new-window, specifically the color and background-color attributes. You can set these however you want, of course; personally, I like a high contrast with colors that aren't likely to appear together on the page itself, so I set them as follows:

background-color: #0ff !important;
color:            #f00 !important;

As the class names suggest, you can set two different sets of colors for following links in the same window and following links in a new window; personally, I keep them the same. This gives them a garish and very distinguishable magenta-on-cyan scheme, like this; awfully hard for that to blend in with anything else.

So surf around for a while and get used to the commands; there are lots more you can learn, too, for which I'll refer you to the wiki page, which has a lot of great information.

Further Customization

Want to block Javascript? There are a number of options out there. I find the easiest is just to block all Javascript, and bind a key combination to enable it if I want it. Put these two lines in your config:

set enable_scripts = 0
@cbind  !ja                = chain 'toggle enable_scripts' 'reload'

This will turn off all Javascript by default, and if you want a page to run its Javascript, hit !ja, and Javascript will be allowed and the page reloaded. Unfortunately, this does not allow the sort of granular control you get in Firefox's Noscript plugin. At present, there doesn't seem to be an equivalent to that functionality with uzbl.