]> git.pld-linux.org Git - packages/kbd.git/blob - kbd.init
- handle unicode in better way
[packages/kbd.git] / kbd.init
1 #!/bin/sh
2
3 # console       Loads console font and keyboard table
4 #
5 # chkconfig:    345 70 30
6 #
7 # description:  Loads the console font, the application-charset map \
8 #               and the keyboard table.
9
10 # This must be executed *after* /usr is mounted.
11 # This means, if /usr is NFS-mounted it needs to
12 # be run after networking and NFS mounts are up.
13
14 [ -f /etc/sysconfig/console ] || exit 0
15
16 [ -f /bin/loadkeys -o -f /usr/bin/loadkeys ] || exit 0
17 [ -f /bin/setfont -o -f /usr/bin/setfont ] || exit 0
18
19 [ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
20
21 # Source function library
22 . /etc/rc.d/init.d/functions
23
24 case "$1" in
25   start|restart|reload|force-reload)
26         . /etc/sysconfig/console
27
28         # Checking if we have framebuffer enabled
29         if [ -f /proc/fb ]; then
30                 # /proc shows as files with size=0, this is workaround
31                 if cat /proc/fb | grep -q "."; then FB=yes; fi
32         fi
33
34         if [ -n "$SVGATEXTMODE" ]; then
35                 run_cmd "Setting Text Mode $SVGATEXTMODE" SVGATextMode $SVGATEXTMODE
36         fi
37
38         case "$LANG" in
39             *.utf8|*.UTF-8)
40             if [ -x /bin/unicode_start ] && /sbin/consoletype fg ; then
41                 unicode_start $SYSFONT $SYSFONTACM
42                 CONSOLEFONT=""
43             fi
44             ;;
45         esac
46
47         if [ -n "$CONSOLEFONT" ]; then
48                 CMD="setfont -m ${CONSOLEMAP:-trivial} $CONSOLEFONT"
49                 show "Loading console font and map"
50                 busy
51
52                 # don't initialize on multiple terminals if we use fbset
53                 # (assume that, in this case fb is loaded as a module)
54                 if [ ! -z "$FB" ]; then
55                         # Check for devfs (workaround: -a option don't work at all)
56                         if [ -d /dev/vc ]; then
57                                 pattern="s/\/dev\/vc\///g"
58                         else
59                                 pattern="s/\/dev\/tty//g"
60                         fi
61
62                         # save old tty number
63                         tty=`/usr/bin/tty | sed $pattern`
64
65                         # check if devfs (workaround: -a option don't work at all)
66                         if [ -d /dev/vc ]; then
67                                 DEVICES="`ls /dev/vc/* | sed 's|/dev/vc/||g'`"
68                         else
69                                 DEVICES="`cat /etc/inittab | grep '^[0-9]*:' | cut -f1 -d :`"
70                         fi
71
72                         [ -z "$SET_FONT_TERMINALS" ] && SET_FONT_TERMINALS="$DEVICES"
73
74                         for cons in $SET_FONT_TERMINALS; do
75                                 /usr/bin/open -c $cons -s -w -- $CMD
76                                 if [ "$NUM_LOCK" ]; then
77                                         if [ $NUM_LOCK = "on" ]; then
78                                                 /usr/bin/open -c $cons -s -w -- /usr/bin/setleds -D +num
79                                         else
80                                                 /usr/bin/open -c $cons -s -w -- /usr/bin/setleds -D -num
81                                         fi
82                                 fi
83                         done
84
85                         if [ "$tty" = "/dev/console" ]; then
86                                 tty=1
87                         fi
88                         /usr/bin/switchto $tty
89                 else
90                         $CMD
91                 fi
92                 ok
93         fi
94         if [ -n "$KEYTABLE" ]; then
95                 run_cmd "Loading keyboard table" loadkeys $KEYTABLE < /dev/tty0 > /dev/tty0
96         fi
97         run_cmd "Enabling SAK sequence" /bin/sh -c "echo Control Alt keycode 101 = SAK | loadkeys"
98
99         power_option=""
100         if [ "$POWER_SAVE" ]; then
101                 if [ "$BLANK_TIME" ]; then
102                         power_option="-blank $BLANK_TIME";
103                 fi
104                 if [ "$POWERDOWN_TIME" ]; then
105                         power_option="-powerdown $POWERDOWN_TIME $power_option";
106                 fi
107                 /usr/bin/setterm $power_option -powersave $POWER_SAVE
108         fi
109         if [ "$FOREGROUND_COLOUR" ]; then
110                 /usr/bin/setterm -foreground $FOREGROUND_COLOUR
111         fi
112         if [ "$BACKGROUND_COLOUR" ]; then
113                 /usr/bin/setterm -background $BACKGROUND_COLOUR
114         fi
115         if [ "$BEEP_LENGTH" ]; then
116                 /usr/bin/setterm -blength $BEEP_LENGTH
117         fi
118         ;;
119   stop)
120         . /etc/sysconfig/console
121         run_cmd "Setting terminals to default values" /usr/bin/setterm -default
122         ;;
123   status)
124         /usr/bin/setleds
125         ;;
126   *)
127         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
128         exit 3
129 esac
130
131 exit 0
This page took 0.067072 seconds and 4 git commands to generate.