|
Packit Service |
50ad14 |
#!/bin/sh
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# 0. Check whether we're on a console
|
|
Packit Service |
50ad14 |
TTY="`/usr/bin/tty`"
|
|
Packit Service |
50ad14 |
case "$TTY" in
|
|
Packit Service |
50ad14 |
/dev/console|/dev/vc*|/dev/tty[0-9]*)
|
|
Packit Service |
50ad14 |
;;
|
|
Packit Service |
50ad14 |
*)
|
|
Packit Service |
50ad14 |
echo "unicode_start skipped on $TTY" >&2
|
|
Packit Service |
50ad14 |
exit 0
|
|
Packit Service |
50ad14 |
;;
|
|
Packit Service |
50ad14 |
esac
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# Enables Unicode processing in the current console.
|
|
Packit Service |
50ad14 |
#
|
|
Packit Service |
50ad14 |
# 1. The input side: the keyboard driver.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# Set the keyboard driver in Unicode mode. (Default is ASCII mode.)
|
|
Packit Service |
50ad14 |
# This really does nothing with the way normal keys are handled in
|
|
Packit Service |
50ad14 |
# the kernel. All it does is:
|
|
Packit Service |
50ad14 |
# - It is necessary for `dumpkeys' in order to not drop U+XXXX
|
|
Packit Service |
50ad14 |
# entries from the keymaps.
|
|
Packit Service |
50ad14 |
# - It is necessary for `loadkeys' in order to avoid warnings.
|
|
Packit Service |
50ad14 |
# - Unicode characters typed as Alt-x1 ... Alt-xn (where x1,...,xn
|
|
Packit Service |
50ad14 |
# are digits on the numeric keypad) will be emitted in UTF-8.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
kbd_mode -u
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# Change the keyboard mapping in such a way that the non-ASCII keys
|
|
Packit Service |
50ad14 |
# produce UTF-8 encoded multibyte sequences, instead of single bytes
|
|
Packit Service |
50ad14 |
# >= 0x80 in a legacy 8-bit encoding.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# Non-root users are allowed to change the unicode mode of their console, but
|
|
Packit Service |
50ad14 |
# not the global keymap. root will have to load the keymap in unicode mode
|
|
Packit Service |
50ad14 |
# explicitly.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
uid="`id -u 2>/dev/null`" ||:
|
|
Packit Service |
50ad14 |
if [ "$uid" = '0' ]; then
|
|
Packit Service |
50ad14 |
# There is no way of reverting the effect of "dumpkeys | loadkeys --unicode",
|
|
Packit Service |
50ad14 |
# the memory of the earlier keymap is lost. Therefore, try
|
|
Packit Service |
50ad14 |
# to save a copy of the original keymap to be able to reload it in unicode_stop.
|
|
Packit Service |
50ad14 |
# (see also http://mail.nl.linux.org/linux-utf8/2003-08/msg00053.html):
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
[ -n "$HOME" -a "$HOME" != '/' ] ||
|
|
Packit Service |
50ad14 |
HOME='/root'
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if [ -d "$HOME" -a -w "$HOME" ]; then
|
|
Packit Service |
50ad14 |
[ -d "$HOME/.kbd" ] ||
|
|
Packit Service |
50ad14 |
mkdir -- "$HOME/.kbd"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
[ ! -w "$HOME/.kbd" ] ||
|
|
Packit Service |
50ad14 |
dumpkeys > "$HOME/.kbd/.keymap_sv"
|
|
Packit Service |
50ad14 |
fi
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# redirect stderr and stdout of loadkeys to /dev/null to avoid the confusing
|
|
Packit Service |
50ad14 |
# "plus before udiaeresis ignored" warnings.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
dumpkeys | loadkeys --unicode > /dev/null 2>&1
|
|
Packit Service |
50ad14 |
fi
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# 2. The output side: the console screen.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# Tell the console output driver that the bytes arriving are UTF-8
|
|
Packit Service |
50ad14 |
# encoded multibyte sequences.
|
|
Packit Service |
50ad14 |
if [ -t 1 -a -t 2 ]; then
|
|
Packit Service |
50ad14 |
printf '\033%%G'
|
|
Packit Service |
50ad14 |
fi
|
|
Packit Service |
50ad14 |
stty iutf8
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
# Tell the graphics card how to display Unicode characters not
|
|
Packit Service |
50ad14 |
# contained in the IBM 437 character set (on PCs). The font should
|
|
Packit Service |
50ad14 |
# have a Unicode map attached, or explicitly specified, e.g.,
|
|
Packit Service |
50ad14 |
# by giving `def.uni' as a second argument.
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
case "$#" in
|
|
Packit Service |
50ad14 |
2)
|
|
Packit Service |
50ad14 |
setfont "$1" -u "$2"
|
|
Packit Service |
50ad14 |
;;
|
|
Packit Service |
50ad14 |
1)
|
|
Packit Service |
50ad14 |
setfont "$1"
|
|
Packit Service |
50ad14 |
;;
|
|
Packit Service |
50ad14 |
0)
|
|
Packit Service |
50ad14 |
;;
|
|
Packit Service |
50ad14 |
*)
|
|
Packit Service |
50ad14 |
echo "usage: unicode_start [font [unicode map]]"
|
|
Packit Service |
50ad14 |
;;
|
|
Packit Service |
50ad14 |
esac
|