Hack96.Browse Graphical Sites from an xterm

Hack 96. Browse Graphical Sites from an xterm

Install the w3m-img extension and view web sites and their images from within a regular xterm.

This book talks a lot about the different types of multimedia on the Web. Generally speaking you want to use a standard web browser to access all of this content, but sometimes it can be useful to test your site against a text-based browser to see how your code holds up. Maybe you just like to browse the Web from a text browser for the sheer geek factor. Whatever the reason, text-based web browsers generally make you miss out on all of the multimedia content on the Webeven the images. In this hack I tell you how to use the w3m browser to look at web sites and their images from an xterm.

When you think about text-based web browsers, usually you think of a browser like lynx or links. Over the past few years, a new text-based web browser called w3m has started to get more use due to its support for complicated layouts, its vi-style navigation, and now, its support for in-line images. With this feature, w3m displays the web page and renders the images within the terminal itself.

It used to be that image rendering was a separate extension to w3m. Nowadays it is part of the full w3m project; however many distributions package the binary with image support in a separate package, so those who don't want the image support can download a smaller binary. w3m is a popular project and has been around for a number of years, so your distribution should have packages available for it. Look specifically for a package labeled w3m-img or something similar, as that will contain the binary with image support. Alternatively you can download and compile the latest version of w3m yourself from the official site at http://w3m.sourceforge.net.

After you have installed w3m with image support, it will automatically load images as it renders a page. Just pass the URL to w3m on the command line, or if w3m is already loaded type U and enter a new URL. For instance, to load Google inside w3m from the command line, type:

 $ w3m  http://www.google.com  

Figure 5-3 shows the default Google page as loaded through w3m. One nice thing about w3m is the fact that you can use the arrow keys to move a cursor around in the web page itself, instead of moving from hyperlink to hyperlink, making it faster to get to the links you want to use. Table 5-2 shows a list of common w3m key bindings.

Figure 5-3. w3m with Google loaded

Table 5-2. Common w3m key bindings




Forward page.


Backward page.

l, right arrow

Cursor right.

h, left arrow

Cursor left.

j, down arrow

Cursor down.

k, up arrow

Cursor up.


Roll up one line.


Roll down one line.


Shift screen right.


Shift screen left.


Shift screen one column right.


Shift screen one column left.


Move to the next hyperlink.


Follow hyperlink.


Save link to file.


Open URL.


Load bookmark.


Add current to bookmark.


Search forward.


Search backward.





Most web pages assume the default background is white, but most terminals default to a black background. When using w3m you might want to launch a terminal with a white background and a dark foreground. To launch an xterm with a white background and a black foreground type:

 $ xterm -fg black -bg white 

Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net