~ubuntu-branches/ubuntu/wily/kbd/wily-proposed

« back to all changes in this revision

Viewing changes to debian/console-screen.kbd.sh

  • Committer: Package Import Robot
  • Author(s): Allison Randal
  • Date: 2011-05-10 14:10:03 UTC
  • mfrom: (1.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20110510141003-spp7i52i1alpqdq9
Tags: 1.15.2-3ubuntu1
* Merge from debian unstable (LP: #779388). Remaining changes:
  - Add setfont, kbd_mode, and loadkeys to initramfs for console-setup.
  - Use ckbcomp to get the keyboard layout if other data files are not
    available.
  - Depend on console-setup, and remove config file; we now only
    support systems using console-setup and so it no longer serves
    a purpose. The removed config file for console-screen has changed
    names from /etc/init.d/console-screen.kbd.sh to /etc/init.d/kbd.
  - Change loadkeys to find any console not in raw mode when invoked
    without an explicit console parameter. (In case the foreground
    console is in raw mode.)
  - Add a 'setvtrgb' utility to configure vt/console colors.
* debian/control:
  - Bump Standards-Version to 3.9.2, no changes needed.
  - Update Build-Depends for debhelper to version 8.1.0.
* Simplify maintainer scripts for conffile removal, using new
  features in updated version of debhelper.
* Add 'setvtrgb' manpage to man8 makefile, so it will install.
* debian/rules: Move 'setvtrgb' binary to extra binaries, as udeb
  binaries are now handled differently.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
### BEGIN INIT INFO
3
 
# Provides:          console-screen
4
 
# Required-Start:    $local_fs $remote_fs
5
 
# Required-Stop:
6
 
# Default-Start:     S
7
 
# Default-Stop:
8
 
# Description: Set console screen modes and fonts
9
 
# Short-Description:    Prepare console
10
 
### END INIT INFO
11
 
 
12
 
# This is the boot script for the `kbd' package.
13
 
# It loads parameters from /etc/kbd/config and maybe loads
14
 
# default font and map.
15
 
# (c) 1997 Yann Dirson
16
 
 
17
 
# If setupcon is present, then we've been superseded by console-setup.
18
 
if type setupcon >/dev/null 2>&1; then
19
 
    exit 0
20
 
fi
21
 
 
22
 
PKG=kbd
23
 
if [ -r /etc/$PKG/config ]; then
24
 
    . /etc/$PKG/config
25
 
fi
26
 
 
27
 
if [ -d /etc/$PKG/config.d ]; then
28
 
    for i in `run-parts --list /etc/$PKG/config.d `; do
29
 
       . $i
30
 
    done
31
 
fi
32
 
 
33
 
# do some magic with the variables for compatibility with the config
34
 
# file of console-tools
35
 
for vc in '' `set | grep "^.*_vc[0-9][0-9]*="  | sed 's/^.*\(_vc[0-9][0-9]*\)=.*/\1/'`
36
 
do
37
 
    eval [ \"\${SCREEN_FONT$vc}\" ] && eval CONSOLE_FONT$vc=\${CONSOLE_FONT$vc:-\${SCREEN_FONT$vc}}
38
 
    eval [ \"\${SCREEN_FONT_MAP$vc}\" ] && eval FONT_MAP$vc=\${FONT_MAP$vc:-\${SCREEN_FONT_MAP$vc}}
39
 
    eval [ \"\${APP_CHARSET_MAP$vc}\" ] && eval CONSOLE_MAP$vc=\${CONSOLE_MAP$vc:-\${APP_CHARSET_MAP$vc}}
40
 
done
41
 
 
42
 
. /lib/lsb/init-functions
43
 
 
44
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
45
 
SETFONT_OPT="-v"
46
 
 
47
 
if which setupcon >/dev/null
48
 
then
49
 
    HAVE_SETUPCON=yes
50
 
fi
51
 
 
52
 
# set DEVICE_PREFIX depending on devfs/udev
53
 
if [ -d /dev/vc ]; then
54
 
    DEVICE_PREFIX="/dev/vc/"
55
 
else
56
 
    DEVICE_PREFIX="/dev/tty"
57
 
fi
58
 
 
59
 
# determine the system charmap
60
 
ENV_FILE=''
61
 
[ -r /etc/environment ] && ENV_FILE="/etc/environment"
62
 
[ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
63
 
[ "$ENV_FILE" ] && CHARMAP=$(set -a && . "$ENV_FILE" && locale charmap)
64
 
if [ "$CHARMAP" = "UTF-8" -a -z "$CONSOLE_MAP" ]
65
 
then
66
 
    UNICODE_MODE=yes
67
 
fi
68
 
 
69
 
reset_vga_palette ()
70
 
{
71
 
    if [ -f /proc/fb ]; then
72
 
        # They have a framebuffer device.
73
 
        # That means we have work to do...
74
 
        echo -n "]R"
75
 
    fi
76
 
}
77
 
 
78
 
unicode_start_stop ()
79
 
{
80
 
    vc=$1
81
 
    if [ -n "$UNICODE_MODE" -a -z "`eval echo \\$CONSOLE_MAP_vc$vc`" ]; then
82
 
        action=unicode_start
83
 
    else
84
 
        action=unicode_stop
85
 
    fi
86
 
    if [ "${CONSOLE_FONT}" ]; then
87
 
        $action "${CONSOLE_FONT}" < ${DEVICE_PREFIX}$vc > ${DEVICE_PREFIX}$vc 2> /dev/null || true
88
 
    else
89
 
        $action < ${DEVICE_PREFIX}$vc > ${DEVICE_PREFIX}$vc 2> /dev/null || true
90
 
    fi
91
 
}
92
 
 
93
 
setup ()
94
 
{
95
 
    # be sure the main program is installed
96
 
    which setfont >/dev/null || return
97
 
 
98
 
    VT="no"
99
 
    # If we can't access the console, quit
100
 
    CONSOLE_TYPE=`fgconsole 2>/dev/null` || return
101
 
 
102
 
    if [ ! $CONSOLE_TYPE = "serial" ]; then
103
 
        readlink /proc/self/fd/0 | grep -q -e /dev/vc -e '/dev/tty[^p]' -e /dev/console
104
 
        if [ $? -eq 0 ]; then
105
 
            VT="yes"
106
 
            reset_vga_palette
107
 
        fi
108
 
    fi
109
 
 
110
 
    [ $VT = "no" ] && return
111
 
 
112
 
    # start vcstime
113
 
    if [ "${DO_VCSTIME}" = "yes" ] && which vcstime >/dev/null; then
114
 
        # Different device name for 2.6 kernels and devfs
115
 
        if [ `uname -r | cut -f 2 -d .` = 6 ] && [ -e /dev/.devfsd ]; then
116
 
            VCSTIME_OPT="-2 /dev/vcsa0"
117
 
        else
118
 
            VCSTIME_OPT=""
119
 
        fi
120
 
        [ "$VERBOSE" != "no" ] && log_action_begin_msg "Starting clock on text console"
121
 
        vcstime ${VCSTIME_OPT} &
122
 
        [ "$VERBOSE" != "no" ] && log_action_end_msg 0
123
 
    fi
124
 
 
125
 
    LIST_CONSOLES=`sed -e '/^ *#/d' /etc/inittab | grep -e '\<tty[0-9]*\>' | awk -F: '{printf "%s ", $1}'`
126
 
 
127
 
    # Global default font+map
128
 
    if [ -z "${HAVE_SETUPCON}" -a "${CONSOLE_FONT}" ]; then
129
 
        [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting up general console font"
130
 
        sfm="${FONT_MAP}" && [ "$sfm" ] && sfm="-u $sfm"
131
 
        acm="${CONSOLE_MAP}" && [ "$acm" ] && acm="-m $acm"
132
 
    
133
 
        # Set for the first 6 VCs (as they are allocated in /etc/inittab)
134
 
        for vc in $LIST_CONSOLES
135
 
        do
136
 
            if ! ( unicode_start_stop $vc \
137
 
                   && setfont -C ${DEVICE_PREFIX}$vc ${SETFONT_OPT} $sfm ${CONSOLE_FONT} $acm )
138
 
            then
139
 
                [ "$VERBOSE" != "no" ] && log_action_end_msg 1
140
 
                break
141
 
            fi
142
 
        done
143
 
        [ "$VERBOSE" != "no" ] && log_action_end_msg 0
144
 
    fi
145
 
 
146
 
    # Default to Unicode mode for new VTs?
147
 
    if [ -f /sys/module/vt/parameters/default_utf8 ]; then
148
 
        if [ -n "$UNICODE_MODE" ]; then
149
 
            echo 1
150
 
        else
151
 
            echo 0
152
 
        fi > /sys/module/vt/parameters/default_utf8
153
 
    fi
154
 
 
155
 
    # Per-VC font+sfm
156
 
    PERVC_FONTS="`set | grep "^CONSOLE_FONT_vc[0-9]*="  | tr -d \' `"
157
 
    if [ -z "${HAVE_SETUPCON}" -a "${PERVC_FONTS}" ]; then
158
 
        [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting up per-VC fonts"
159
 
        for font in ${PERVC_FONTS}
160
 
        do
161
 
            # extract VC and FONTNAME info from variable setting
162
 
            vc=`echo $font | cut -b16- | cut -d= -f1`
163
 
            eval font=\$CONSOLE_FONT_vc$vc
164
 
            # eventually find an associated SFM
165
 
            eval sfm=\${FONT_MAP_vc${vc}}
166
 
            [ "$sfm" ] && sfm="-u $sfm"
167
 
            if ! ( unicode_start_stop $vc \
168
 
                   && setfont -C ${DEVICE_PREFIX}$vc ${SETFONT_OPT} $sfm $font )
169
 
            then
170
 
                [ "$VERBOSE" != "no" ] && log_action_end_msg 1
171
 
                break
172
 
            fi
173
 
        done
174
 
        [ "$VERBOSE" != "no" ] && log_action_end_msg 0
175
 
    fi
176
 
 
177
 
 
178
 
    # Per-VC ACMs
179
 
    PERVC_ACMS="`set | grep "^CONSOLE_MAP_vc[0-9]*="  | tr -d \' `"
180
 
    if [ -z "${HAVE_SETUPCON}" -a "${PERVC_ACMS}" ]; then
181
 
        [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting up per-VC ACM's"
182
 
        for acm in ${PERVC_ACMS}
183
 
          do
184
 
          # extract VC and ACM_FONTNAME info from variable setting
185
 
          vc=`echo $acm | cut -b15- | cut -d= -f1`
186
 
          eval acm=\$CONSOLE_MAP_vc$vc
187
 
          if ! setfont -C "${DEVICE_PREFIX}$vc" ${SETFONT_OPT} -m "$acm"; then
188
 
              [ "$VERBOSE" != "no" ] && log_action_end_msg 1
189
 
              break
190
 
          fi
191
 
        done
192
 
        [ "$VERBOSE" != "no" ] && log_action_end_msg 0
193
 
    fi
194
 
    
195
 
 
196
 
    # screensaver stuff
197
 
    setterm_args=""
198
 
    if [ "$BLANK_TIME" ]; then
199
 
        setterm_args="$setterm_args -blank $BLANK_TIME"
200
 
    fi
201
 
    if [ "$BLANK_DPMS" ]; then
202
 
        setterm_args="$setterm_args -powersave $BLANK_DPMS"
203
 
    fi
204
 
    if [ "$POWERDOWN_TIME" ]; then
205
 
        setterm_args="$setterm_args -powerdown $POWERDOWN_TIME"
206
 
    fi
207
 
    if [ "$setterm_args" ]; then
208
 
        setterm $setterm_args 
209
 
    fi
210
 
 
211
 
    # Keyboard rate and delay
212
 
    KBDRATE_ARGS=""
213
 
    if [ -n "$KEYBOARD_RATE" ]; then
214
 
        KBDRATE_ARGS="-r $KEYBOARD_RATE"
215
 
    fi
216
 
    if [ -n "$KEYBOARD_DELAY" ]; then
217
 
        KBDRATE_ARGS="$KBDRATE_ARGS -d $KEYBOARD_DELAY"
218
 
    fi
219
 
    if [ -n "$KBDRATE_ARGS" ]; then
220
 
        [ "$VERBOSE" != "no" ] && log_action_begin_msg "Setting keyboard rate and delay"
221
 
        kbdrate -s $KBDRATE_ARGS
222
 
        [ "$VERBOSE" != "no" ] && log_action_end_msg 0
223
 
    fi
224
 
 
225
 
    # Inform gpm if present, of potential changes.
226
 
    if [ -f /var/run/gpm.pid ]; then
227
 
        kill -WINCH `cat /var/run/gpm.pid` 2> /dev/null
228
 
    fi
229
 
 
230
 
    # Allow user to remap keys on the console
231
 
    if [ -z "${HAVE_SETUPCON}" -a -r /etc/$PKG/remap ]; then
232
 
        dumpkeys < ${DEVICE_PREFIX}1 | sed -f /etc/$PKG/remap | loadkeys --quiet
233
 
    fi
234
 
 
235
 
    # Set LEDS here
236
 
    if [ -n "$LEDS" ]; then
237
 
        for i in $LIST_CONSOLES
238
 
        do
239
 
            setleds -D $LEDS < $DEVICE_PREFIX$i
240
 
        done
241
 
    fi
242
 
}
243
 
 
244
 
case "$1" in
245
 
    start|reload|restart|force-reload)
246
 
        if [ -n "$HAVE_SETUPCON" ]
247
 
        then
248
 
                log_action_msg "Setting console screen modes"
249
 
        else
250
 
                log_action_msg "Setting console screen modes and fonts"
251
 
        fi
252
 
        setup
253
 
        ;;
254
 
    stop)
255
 
        ;;
256
 
    *)
257
 
        setup
258
 
        ;;
259
 
esac
260
 
 
261
 
:
262