From e27ff4beafd8fdb9593e1b0eee294ec969a793b0 Mon Sep 17 00:00:00 2001 From: Roman Kyrylych Date: Thu, 28 Feb 2008 13:55:41 +0200 Subject: [PATCH] Make non-UTF-8 consoles work correctly in .24+ kernels * Since 2.6.24 the virtual terminal is in UTF-8 mode and the keyboard is in Unicode mode by default, and configurable only at run-time. * To make non-UTF-8 consoles work correctly: - the non-UTF-8 mode is set for the virtual terminal, - the XLATE mode is set for the keyboard. * UTF-8 mode is still set explicitly (not relying on default), so console works correctly even in a case when user set vt.default_utf8=0 in kernel commandline, but LOCALE in rc.conf is *.UTF-8. * % is a special symbol for printf, so it should be written twice. Signed-off-by: Roman Kyrylych --- rc.sysinit | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 0e83c8b..1dae885 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -370,17 +370,29 @@ echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh stat_done if echo "$LOCALE" | /bin/grep -qi utf ; then - stat_busy "Setting Consoles to UTF-8" + stat_busy "Setting Consoles to UTF-8 mode" + # UTF-8 consoles are default since 2.6.24 kernel + # this code is needed not only for older kernels, + # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. /usr/bin/kbd_mode -u for i in $(seq 1 63); do - printf "\e%G" > /dev/vc/${i} + printf "\e%%G" > /dev/vc/${i} done # the $CONSOLE check helps us avoid this when running scripts from cron - echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e%G"; fi' >>/etc/profile.d/locale.sh + echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e%%G"; fi' >>/etc/profile.d/locale.sh stat_done - status "Loading Keyboard Map: $KEYMAP in utf-8 mode" /bin/loadkeys -q -u $KEYMAP + status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q -u $KEYMAP else - status "Loading Keyboard Map: $KEYMAP in legacy mode" /bin/loadkeys -q $KEYMAP + stat_busy "Setting Consoles to legacy mode" + # make non-UTF-8 consoles work on 2.6.24 and newer kernels + /usr/bin/kbd_mode -a + for i in $(seq 1 63); do + printf "\e%%@" > /dev/vc/${i} + done + # the $CONSOLE check helps us avoid this when running scripts from cron + echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e%%@"; fi' >>/etc/profile.d/locale.sh + stat_done + status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q $KEYMAP fi if [ -n "$CONSOLEFONT" ]; then -- 1.5.3.7