w3m and GNU Screen

by Charles Fry
Janurary 2004

As screen facilitates all things text, it is natural to want to use it to browse the web. There are plenty of text-based web browsers available, including lynx, links, and w3m. One of the nice features in w3m is its ability to display inline images on X terminals such as xterm and rxvt. While this can enrich the text-browsing experience, there is the potential for some negative interactions with screen which must be dealt with explicitly.

w3m displays images to the terminal in which it was executed, independent of where the embedding screen session is being displayed. For example, if w3m were invoked inside of screen in Terminal 1, afterwhich the screen session was detached and then reattached from Terminal 2, w3m's images would continue to display in Terminal 1.

The primary workaround to this complication is to ensure that screens running w3m are never detached. New connections can still be made using the -x command-line option; in which case all screens would be functional, but only the original screen would display inline images in its termial. Admittedly, not being able to detach from screen will probably run against the grain of habitual screen usage. This can be partially accomodated by running a seperate instance of screen for the sole purpose of web browsing. When the terminal running the web browsing screen closed, w3m would continue to function but would cease displaying inline images. Alternatively, autodetach could be turned off with the following command:

autodetach off

This tells screen not to automatically detach upon hangup. While this doesn't prevent manual detachment, it effectively terminates the screen session when the embedding terminal is closed. This essentially mimics the behavior of running w3m outside of screen, but has the disadvantage that all current browsing sessions will be mercilessly closed.