3 # 0. Check whether we're on a console
6 /dev/console|/dev/vc*|/dev/tty[0-9]*)
9 echo "unicode_start skipped on $TTY" >&2
14 # Enables Unicode processing in the current console.
17 if [ ! -e /proc/self/fd/0 ] ; then
18 echo "Won't set unicode mode: Can't determine console type;" >&2
19 echo " Please ensure that /proc is mounted." >&2
23 readlink /proc/self/fd/0 | grep -q -e /dev/vc -e '/dev/tty[^p]' -e /dev/console
25 echo "Won't set unicode mode: not a VT." >&2
29 # 1. The input side: the keyboard driver.
31 # Set the keyboard driver in Unicode mode. (Default is ASCII mode.)
32 # This really does nothing with the way normal keys are handled in
33 # the kernel. All it does is:
34 # - It is necessary for `dumpkeys' in order to not drop U+XXXX
35 # entries from the keymaps.
36 # - It is necessary for `loadkeys' in order to avoid warnings.
37 # - Unicode characters typed as Alt-x1 ... Alt-xn (where x1,...,xn
38 # are digits on the numeric keypad) will be emitted in UTF-8.
42 # Change the keyboard mapping in such a way that the non-ASCII keys
43 # produce UTF-8 encoded multibyte sequences, instead of single bytes
44 # >= 0x80 in a legacy 8-bit encoding.
46 # Non-root users are allowed to change the unicode mode of their console, but
47 # not the global keymap. root will have to load the keymap in unicode mode
50 uid="`id -u 2>/dev/null`" ||:
51 if [ "$uid" = '0' ]; then
52 # There is no way of reverting the effect of "dumpkeys | loadkeys --unicode",
53 # the memory of the earlier keymap is lost. Therefore, try
54 # to save a copy of the original keymap to be able to reload it in unicode_stop.
55 # (see also http://mail.nl.linux.org/linux-utf8/2003-08/msg00053.html):
57 [ -n "$HOME" -a "$HOME" != '/' ] ||
60 if [ -d "$HOME" -a -w "$HOME" ]; then
61 [ -d "$HOME/.kbd" ] ||
64 [ ! -w "$HOME/.kbd" ] ||
65 dumpkeys > "$HOME/.kbd/.keymap_sv"
68 # redirect stderr and stdout of loadkeys to /dev/null to avoid the confusing
69 # "plus before udiaeresis ignored" warnings.
71 dumpkeys | loadkeys --unicode > /dev/null 2>&1
74 # 2. The output side: the console screen.
76 # Tell the console output driver that the bytes arriving are UTF-8
77 # encoded multibyte sequences.
78 if [ -t 1 -a -t 2 ]; then
83 # Tell the graphics card how to display Unicode characters not
84 # contained in the IBM 437 character set (on PCs). The font should
85 # have a Unicode map attached, or explicitly specified, e.g.,
86 # by giving `def.uni' as a second argument.
98 echo "usage: unicode_start [font [unicode map]]"