Attached is a new version of the "console" script for LFS 6.x. The
difference from the stock version is that the new script tries to guess
the screen font based on the user's locale settings.

To test the script, put it into /etc/rc.d/init.d/ directory instead of
the old version, remove (or comment out) the FONT=... line in
/etc/sysconfig/console, and add LANG=your_locale there instead.

I have not implemented keymap guessing because even for the same locale
preferences may differ depending on the exact keyboard model.

Please report whether this script guesses your screen font correctly
(also please specify your locale). Suboptimal but not strictly incorrect
guesses should be explained (i.e. what exactly is suboptimal).

Test results should go to the lfs-support list.

--
Alexander E. Patrakov

#!/bin/sh
########################################################################
# Begin $rc_base/init.d/console
#
# Description : Sets keymap and screen font (LiveCD version)
#
# Authors     : Gerard Beekmans - [EMAIL PROTECTED]
#               Alexander E. Patrakov
#
# Version     : 00.00-livecd
#
# Notes       : Unlike the stock "console" script, this version guesses
#               the correct font based on the user's locale.
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

# Native English speakers probably don't have /etc/sysconfig/console at all
if [ -f /etc/sysconfig/console ]; then
        . /etc/sysconfig/console
fi


guess_font() {
        CHARMAP=`locale charmap`

        FONTTABLE='
#Charset:FONT:ERROR_FLAG:CAVEAT
ANSI_X3.4-1968::0:You forgot to (correctly) set your locale!
BIG5::1:Chinese is not supported by this Live CD. Sorry.
BIG5-HKSCS::1:Chinese is not supported by this Live CD. Sorry.
CP1251:ruscii_8x16 -m cp1251:0:
CP1255:LatArCyrHeb-16 -m 8859-8:0:The "kbd" package does not support CP1255 
encoding, using ISO-8859-8 instead.
EUC-JP::1:Japanese is not supported by this Live CD. Sorry.
EUC-KR::1:Korean is not supported by this Live CD. Sorry.
EUC-TW::1:Chinese is not supported by this Live CD. Sorry.
GB18030::1:Chinese is not supported by this Live CD. Sorry.
GB2312::1:Chinese is not supported by this Live CD. Sorry.
GBK::1:Chinese is not supported by this Live CD. Sorry.
GEORGIAN-PS::1:Georgian is not supported by this Live CD. Sorry.
ISO-8859-1:lat1-16 -m 8859-1:0:
ISO-8859-2:lat2a-16 -m 8859-2:0:
#ISO-8859-3:iso03.16 -m 8859-3:0:Line drawing characters are not available with 
this font.
ISO-8859-3:LatArCyrHeb-16 -m 8859-3:0:Bright colors are not available with this 
font.
#ISO-8859-5:iso05.16 -m 8859-5:0:Line drawing characters are not available with 
this font.
ISO-8859-5:LatArCyrHeb-16 -m 8859-5:0:Bright colors are not available with this 
font.
#ISO-8859-6:iso06.16 -m 8859-6:0:Line drawing characters are not available with 
this font.
ISO-8859-6:LatArCyrHeb-16 -m 8859-6:0:Bright colors are not available with this 
font.
ISO-8859-7:iso07u-16 -m 8859-7:0:
ISO-8859-8:LatArCyrHeb-16 -m 8859-8:0:Bright colors are not available with this 
font.
ISO-8859-9:cp857.16 -u /usr/share/kbd/consoletrans/cp857_to_uni.trans -m 
8859-9:0:
#ISO-8859-10:iso10.16 -m 8859-10:0:Line drawing characters are not available 
with this font.
ISO-8859-10:LatArCyrHeb-16 -m 8859-10:0:Bright colors are not available with 
this font.
#ISO-8859-13:lat7-14 -m 8859-13:0:Line drawing characters are not available 
with this font.
ISO-8859-13:LatArCyrHeb-16 -m 8859-13:0:Bright colors are not available with 
this font.
ISO-8859-14::1:Welsh is not supported by this Live CD. Sorry.
ISO-8859-15:lat0-16 -m 8859-15:0:
#KOI8-R:koi8r-8x16 -u koi8r -m koi8-r:0:This font is ugly.
KOI8-R:ruscii_8x16 -m koi8-r:0:
KOI8-T:ruscii_8x16 -m koi8-r:0:The "kbd" package does not support KOI8-T 
encoding, using KOI8-R instead.
KOI8-U:ruscii_8x16 -m koi8-u:0:
PT154:ruscii_8x16 -m cp1251:0:The "kbd" package does not support PT154 
encoding, using CP1251 instead.
TCVN5712-1::1:Vietnamese is not supported by this Live CD. Sorry.
TIS-620::1:Thai is not supported by this Live CD. Sorry.
UTF-8:LatArCyrHeb-16:0:\033%GThis Live CD does not officially support UTF-8.
'

        FONTLINE=`echo "$FONTTABLE" | egrep "^$CHARMAP:"`
        FONT=`echo "$FONTLINE" | cut -d ":" -f 2`
        ERROR=`echo "$FONTLINE" | cut -d ":" -f 3`
        FONT_PROBLEM=`echo "$FONTLINE" | cut -d ":" -f 4`

        return $ERROR
}

case "${1}" in
        start)
                if [ -n "${KEYMAP}" ]; then
                        boot_mesg "Loading keymap: ${KEYMAP}..."
                        loadkeys ${KEYMAP} &>/dev/null
                        evaluate_retval
                fi

                if [ -n "${KEYMAP_CORRECTIONS}" ]; then
                        boot_mesg "Loading keymap corrections: 
${KEYMAP_CORRECTIONS}..."
                        loadkeys ${KEYMAP_CORRECTIONS} &>/dev/null
                        evaluate_retval
                fi

                if [ -n "${FONT}" ]; then
                        boot_mesg "Setting screen font to ${FONT}..."
                        setfont $FONT &>/dev/null
                        evaluate_retval
                else
                        guess_font
                        FONT="${FONT-default8x16}"
                        boot_mesg "Setting screen font to ${FONT}..."
                        boot_mesg_flush
                        setfont $FONT &>/dev/null
                        if [ ! -z "$FONT_PROBLEM" ] ; then
                                boot_mesg "WARNING:\n${FONT_PROBLEM}" ${WARNING}
                                boot_mesg_flush
                        fi
                        ( exit $ERROR )
                        evaluate_retval
                fi
                ;;
        *)
                echo "Usage: ${0} {start}"
                exit 1
                ;;
esac

# End $rc_base/init.d/console

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to