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.
16 # 1. The input side: the keyboard driver.
18 # Set the keyboard driver in Unicode mode. (Default is ASCII mode.)
19 # This really does nothing with the way normal keys are handled in
20 # the kernel. All it does is:
21 # - It is necessary for `dumpkeys' in order to not drop U+XXXX
22 # entries from the keymaps.
23 # - It is necessary for `loadkeys' in order to avoid warnings.
24 # - Unicode characters typed as Alt-x1 ... Alt-xn (where x1,...,xn
25 # are digits on the numeric keypad) will be emitted in UTF-8.
29 # Change the keyboard mapping in such a way that the non-ASCII keys
30 # produce UTF-8 encoded multibyte sequences, instead of single bytes
31 # >= 0x80 in a legacy 8-bit encoding.
33 # Non-root users are allowed to change the unicode mode of their console, but
34 # not the global keymap. root will have to load the keymap in unicode mode
37 uid="`id -u 2>/dev/null`" ||:
38 if [ "$uid" = '0' ]; then
39 # There is no way of reverting the effect of "dumpkeys | loadkeys --unicode",
40 # the memory of the earlier keymap is lost. Therefore, try
41 # to save a copy of the original keymap to be able to reload it in unicode_stop.
42 # (see also http://mail.nl.linux.org/linux-utf8/2003-08/msg00053.html):
44 [ -n "$HOME" -a "$HOME" != '/' ] ||
47 if [ -d "$HOME" -a -w "$HOME" ]; then
48 [ -d "$HOME/.kbd" ] ||
51 [ ! -w "$HOME/.kbd" ] ||
52 dumpkeys > "$HOME/.kbd/.keymap_sv"
55 # redirect stderr and stdout of loadkeys to /dev/null to avoid the confusing
56 # "plus before udiaeresis ignored" warnings.
58 dumpkeys | loadkeys --unicode > /dev/null 2>&1
61 # 2. The output side: the console screen.
63 # Tell the console output driver that the bytes arriving are UTF-8
64 # encoded multibyte sequences.
65 if [ -t 1 -a -t 2 ]; then
70 # Tell the graphics card how to display Unicode characters not
71 # contained in the IBM 437 character set (on PCs). The font should
72 # have a Unicode map attached, or explicitly specified, e.g.,
73 # by giving `def.uni' as a second argument.
85 echo "usage: unicode_start [font [unicode map]]"