How Can I Change The Backgound Color in Lynx From `lynx.cfg`?

I am using this script, from another stack extange post. It allows me to force Lynx to use the proper terminal colors. The issue is that the backgound color is incorrect, and it is reading the 7th terminal color instead of the actual terminal background. How would I override the background color (including the color behind selections that are intended to be the background color)?

For this to work it would have to be done in the lynx.cfg because the lynx.lss is blank. Here is the current script:

#!/bin/sh
# invoke lynx built with color-style, overriding the color options to use the
# non-color-style scheme -TD

my_cfg=${TMPDIR:-/tmp}/lynxcfg$$
my_lss=${TMPDIR:-/tmp}/lynxlss$$
trap "rm -f $my_lss $my_cfg" 0 1 2 5 15

echo >$my_lss

rm -f "$my_cfg"
echo "DEFAULT_COLORS:off" >>$my_cfg
if test -n "$LYNX_CFG" ; then
        echo "include:$LYNX_CFG" >>$my_cfg
fi
echo "COLOR_STYLE:" >>$my_cfg
echo "NESTED_TABLES:off" >>$my_cfg

LYNX_CFG=$my_cfg
export LYNX_CFG
LYNX_LSS=$my_lss
export LYNX_LSS

${LYNX_PROG-lynx} "$@"
Asked By: VehementHam

||

The normal foreground/background colors in the non-color-style arrangement are the first COLOR setting.

Here is a modified oldlynx which uses that (along with enabling DEFAULT_COLORS) to use the terminal’s default background color:

#!/bin/sh
# invoke lynx built with color-style, overriding the color options to use the
# non-color-style scheme -TD

my_cfg=${TMPDIR:-/tmp}/lynxcfg$$
my_lss=${TMPDIR:-/tmp}/lynxlss$$
trap "rm -f $my_lss $my_cfg" 0 1 2 3 15

echo >$my_lss 

rm -f "$my_cfg"
echo "DEFAULT_COLORS:on" >>$my_cfg
if test -n "$LYNX_CFG" ; then
        echo "include:$LYNX_CFG" >>$my_cfg
fi
cat >>$my_cfg <<EOF
COLOR_STYLE:
NESTED_TABLES:off
COLOR:0:blue:default
EOF

LYNX_CFG=$my_cfg
export LYNX_CFG
LYNX_LSS=$my_lss
export LYNX_LSS

${LYNX_PROG-lynx} "$@"

A screenshot shows the effect (the terminal’s background is white):
screenshot with default colors

Answered By: Thomas Dickey
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.