Split terminal encoding out.

This commit is contained in:
Roy Marples 2008-03-27 13:49:49 +00:00
parent b271ac5af5
commit d09f9f47eb
5 changed files with 56 additions and 26 deletions

View File

@ -1,5 +1,5 @@
SRCS+= hwclock.in consolefont.in keymaps.in modules.in mtab.in numlock.in \
procfs.in
procfs.in termencoding.in
.SUFFIXES: .Linux.in
.Linux.in:

View File

@ -6,8 +6,7 @@ description="Sets a font for the consoles."
depend()
{
need localmount
need keymaps # sets up terminal encoding scheme
need localmount termencoding
after hotplug
keyword noopenvz noprefix nouml novserver noxenu
}
@ -34,7 +33,7 @@ start()
return 0
fi
local x= param= sf_param= retval=0 ttydev=
local x= param= sf_param= retval=0 ttydev=/dev/tty
# Get additional parameters
if [ -n "${consoletranslation}" ]; then
@ -46,10 +45,7 @@ start()
# Set the console font
ebegin "Setting user font"
[ -d /dev/vc ] \
&& ttydev=/dev/vc/ \
|| ttydev=/dev/tty
[ -d /dev/vc ] && ttydev=/dev/vc/
x=1
while [ ${x} -le ${ttyn} ]; do
setfont ${consolefont} ${param} -C ${ttydev}${x} >/dev/null
@ -61,17 +57,17 @@ start()
# Store the last font so we can use it ASAP on boot
if [ ${retval} -eq 0 -a -w "${RC_LIBDIR}" ]; then
mkdir -p "${RC_LIBDIR}"/console
for font in /usr/share/consolefonts/"${consolefont}".*; do
:
done
cp "${font}" "${RC_LIBDIR}"/console
echo "${font##*/}" > "${RC_LIBDIR}"/console/font
if yesno ${unicode:-${UNICODE}}; then
cp /dev/null "${RC_LIBDIR}"/console/unicode
echo "" > "${RC_LIBDIR}"/console/unicode
else
rm -f "${RC_LIBDIR}"/console/unicode
fi
fi
return ${retval}

View File

@ -14,7 +14,7 @@ dumpkeys_charset=${dumpkeys_charset:-${DUMPKEYS_CHARSET}}
depend()
{
need localmount
need localmount termencoding
keyword noopenvz noprefix nouml novserver noxenu
}
@ -25,43 +25,41 @@ start()
return 1
fi
local ttydev= n=
[ -d /dev/vc ] \
&& ttydev=/dev/vc/ \
|| ttydev=/dev/tty
local ttydev=/dev/tty n=
[ -d /dev/vc ] && ttydev=/dev/vc/
# Force linux keycodes for PPC.
if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]; then
echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes
fi
ebegin "Loading key mappings"
local loadkeys_uni= wkeys=
yesno ${unicode} && loadkeys_uni="--unicode"
ebegin "Loading key mappings (${keymap})"
local loadkeys_uni= wkeys= kmode="-a" msg="ASCII"
if yesno ${unicode}; then
loadkeys_uni="--unicode"
kmode="-u"
msg="UTF-8"
fi
yesno ${windowskeys} && wkeys="windowkeys"
loadkeys -q ${loadkeys_uni} ${wkeys} ${keymap} ${extended_keymaps}
eend $? "Error loading key mappings" || return $?
if yesno ${fix_euro}; then
ebegin "Fixing font for euro symbol"
# Fix some fonts displaying the Euro, #173528.
echo "altgr keycode 18 = U+20AC" | loadkeys -q
eend $?
fi
# Set terminal encoding to either ASCII or UNICODE.
# See utf-8(7) for more information.
local termencoding="%@" termmsg="ASCII" kmode="-a"
ebegin "Setting keyboard mode to ${msg}"
if yesno ${unicode}; then
dumpkeys ${dumpkeys_charset:+-c} \
${dumpkeys_charset} | loadkeys --unicode
termencoding="%G"
termmsg="UTF-8"
kmode="-u"
fi
ebegin "Setting terminal encoding to" ${termmsg}
n=1
while [ ${n} -le "${ttyn}" ]; do
printf "\033%s" "${termencoding}" >"${ttydev}${n}"
kbd_mode "${kmode}" -C "${ttydev}${n}"
n=$((${n} + 1))
done

35
init.d/termencoding.in Normal file
View File

@ -0,0 +1,35 @@
#!@PREFIX@/sbin/runscript
# Copyright 2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
description="Configures terminal encoding."
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
unicode=${unicode:-${UNICODE}}
depend()
{
keyword noopenvz noprefix nouml novserver noxenu
}
start()
{
local ttydev=/dev/tty n=
[ -d /dev/vc ] && ttydev=/dev/vc/
# Set terminal encoding to either ASCII or UNICODE.
# See utf-8(7) for more information.
local termencoding="%@" termmsg="ASCII"
if yesno ${unicode}; then
termencoding="%G"
termmsg="UTF-8"
fi
ebegin "Setting terminal encoding to ${termmsg}"
n=1
while [ ${n} -le "${ttyn}" ]; do
printf "\033%s" "${termencoding}" >"${ttydev}${n}"
n=$((${n} + 1))
done
eend 0
}

View File

@ -1,2 +1,3 @@
BOOT+= hwclock consolefont keymaps modules mtab net.lo procfs
BOOT+= hwclock consolefont keymaps modules mtab net.lo procfs \
termencoding
DEFAULT+= hdparm