Setting up elinks.conf

If you have old configuration files from old ELinks versions or from Links, then you may use the script (which is placed at contrib/conv/ on the source distribution) to convert them to the new format. If you don't use it you will need to edit the configuration file, and here you will find how.

Associating a file extension to a MIME type

You can still do this with the UI, from the the Setup->File Extensions submenu.

If you want to do so from the configuration file, enter set mime.extension.ext = "type", replacing ext with the appropriate file extension, and type with its MIME type. E.g. you may want to have set mime.extension.jpg = "image/jpeg".

Defining a handler

For each handler you must define three items, specifying in what context the value of the item should be applied. You must enter set mime.handler.handler-name.item.context = value, replacing handler-name with the name for the handler you are defining, item with the item you are defining for this handler, context with the context this item value is to be applied, and value with the value you want to assign to the item. You must do so for each of the available items: program, ask and block.

The value for program is a string with the exact command you want to be issued to view the file, placing % were you would put the file name. The values for ask and block are either 0 (no) or 1 (yes). Available contexts include unix and unix-xwin, which mean UNIX text terminal and X respectively (others can be os2, win32, beos, riscos, …). The latter does not mean you are running ELinks from X, just that the DISPLAY variable is set so that ELinks may run an X program.

To illustrate it, here is an example. Suppose you want to define the image_viewer handler which should be used to view images. The configuration file may look like this:

set mime.handler.image_viewer.unix.ask = 1
set mime.handler.image_viewer.unix-xwin.ask = 0

set mime.handler.image_viewer.unix.block = 1
set mime.handler.image_viewer.unix-xwin.block = 0

set mime.handler.image_viewer.unix.program = "zgv %"
set mime.handler.image_viewer.unix-xwin.program = "xli %"

In this example the image_viewer handler uses the svgalib image viewer zgv when X is not available, and the X image viewer xli when it is. The terminal would be blocked when X is not available and it would not be when it's available. Finally, ELinks would ask for confirmation before using the handler only with X not available.

Associating a MIME type to a handler

Just enter set = "handler", replacing class with the class for the mime type, name with the specific name within that class, and handler with the name for the handler you want to assign to the MIME type. E.g. you may want to have set mime.type.image.jpeg = "image_viewer".