65
65
-f, --font-only setup the font only, do not setup the keyboard
66
66
--force do not check whether we are on the console
67
67
-v, --verbose explain what is being doing, try it if s.t. goes wrong
68
--save copy the font and the ACM in /etc/console-setup,
68
--save copy the font and the console map in /etc/console-setup,
69
69
update /etc/console-setup/cached.kmap.gz
70
70
--save-only only save; don't setup keyboard/font immediately
72
72
-h, --help display this help and exit
74
74
If VARIANT is not specified setupcon looks for the configuration files
75
(in this order) ~/.console-setup and /etc/default/console-setup. When
75
(in this order) ~/.console-setup and if this doesn't exist then the
76
combination/etc/default/keyboard + /etc/default/console-setup. When
76
77
a VARIANT is specified then setupcon looks for the configuration files
77
78
~/.console-setup.VARIANT and /etc/default/console-setup.VARIANT.
97
98
if [ "$VARIANT" ]; then
98
99
USER_CONFIG=${HOME}/.console-setup."$VARIANT"
99
MAIN_CONFIG=/etc/default/console-setup."$VARIANT"
100
MAIN_CONFIG=/etc/default/keyboard."$VARIANT"
101
MAIN_CONFIG2=/etc/default/console-setup."$VARIANT"
101
103
USER_CONFIG=${HOME}/.console-setup
102
MAIN_CONFIG=/etc/default/console-setup
104
MAIN_CONFIG=/etc/default/keyboard
105
MAIN_CONFIG2=/etc/default/console-setup
105
108
if [ -f "$USER_CONFIG" ]; then
106
109
CONFIG="$USER_CONFIG"
108
112
elif [ -f "$MAIN_CONFIG" ]; then
109
113
CONFIG="$MAIN_CONFIG"
114
CONFIG2="$MAIN_CONFIG2"
111
116
echo "setupcon: None of $MAIN_CONFIG nor $USER_CONFIG exists." >&2
120
if [ "$CONFIG2" -a -f "$CONFIG2" ]; then
117
if [ -d /lib/debian-installer ]; then
121
125
if [ "$verbose_option" = yes ]; then
122
126
VERBOSE_OUTPUT=yes
139
143
/dev/tty[0-9]*|/dev/vc/[0-9]*|/dev/console)
142
if [ "$VERBOSE_OUTPUT" = yes ]; then
143
echo We are not on the Linux console, exiting.
146
echo We are not on the Linux console, the console is left unconfigured.
152
ACTIVE_CONSOLES=${ACTIVE_CONSOLES:-/dev/tty[1-6]}
153
CHARMAP=${CHARMAP:-UTF-8}
154
CODESET=${CODESET:-Uni2}
155
CONSOLE_MAP=${CONSOLE_MAP:-$ACM}
150
157
#-----------------------#
152
159
#-----------------------#
156
163
if [ "$save_only" != yes ]; then
157
164
for console in $ACTIVE_CONSOLES; do
158
165
[ -w $console ] || continue
159
if [ "$CHARMAP" = UTF-8 ] || [ -z "$ACM$CHARMAP" ]; then
167
[ "$CHARMAP" = UTF-8 ] || [ -z "$CONSOLE_MAP$CHARMAP" ]
160
169
printf '\033%%G' >$console
162
171
printf '\033%%@' >$console
168
177
if [ -z "$FONT" ]; then
169
179
if which ckbcomp-mini >/dev/null; then
170
FONT=$(echo `ls /usr/share/consolefonts/$CODESET-*.psf.gz \
180
FONT=$(echo `ls /usr/share/consolefonts/$CODESET-*.psf* \
181
/etc/console-setup/$CODESET-*.psf* 2>/dev/null`)
183
if [ "$FONTFACE" ] || [ "$FONTSIZE" ]; then
184
eval echo setupcon: Warning: ignoring the FONTFACE and FONTSIZE specifications! $verbose
173
186
elif [ "$FONTFACE" ] && [ "$FONTSIZE" ]; then
174
187
FONT="$CODESET-$FONTFACE$FONTSIZE.psf.gz"
175
188
case "$FONTSIZE" in
204
217
if [ "$dir" = FONT_IS_MISSING ]; then
205
echo setupcon: Warning: the font ${f##*/} does not exists! >&2
218
echo setupcon: Warning: the font ${f##*/} does not exist! >&2
224
for f in $FONT_MAP; do
225
[ -z "$LOADFONT_MAP" ] || break # only one unicode map
227
LOADFONT_MAP="$LOADFONT_MAP $f"
230
/usr/local/share/consoletrans \
231
/usr/share/consoletrans \
235
if [ -f "$dir/${f##*/}" ]; then
236
LOADFONT_MAP="$LOADFONT_MAP $dir/${f##*/}"
239
if [ "$dir" = FONT_MAP_IS_MISSING ]; then
240
echo setupcon: Warning: the unicode map ${f##*/} does not exist! >&2
222
257
rm -f "/etc/console-setup/${fdec##*/}.gz"
260
for f in $LOADFONT_MAP; do
263
&& [ "${f%/*}" != /etc/console-setup ]
265
cp "$f" /etc/console-setup/
269
# Due to bug in splashy and usplash: do not load fonts (#540314)
271
pidof splashy > /dev/null \
272
|| pidof usplash > /dev/null
227
277
if [ "$save_only" != yes ] && [ "$LOADFONTS" ]; then
228
278
for console in $ACTIVE_CONSOLES; do
229
279
[ -w $console ] || continue
231
281
if [ "$bigfont" = yes ]; then
232
282
echo "setupcon: The consolechars utility from the console-setup font can load only fonts with 8 pixel width matrix. Please install the setfont utility from the kbd package." >&2
234
eval consolechars -v --tty=$console -f $LOADFONTS $verbose
284
if [ "$LOADFONT_MAP" ]; then
285
eval consolechars -v --tty=$console -f $LOADFONTS -u "$LOADFONT_MAP" $verbose
287
eval consolechars -v --tty=$console -f $LOADFONTS $verbose
235
289
elif which setfont >/dev/null; then
236
eval setfont -v -C $console $LOADFONTS $verbose
290
if [ "$LOADFONT_MAP" ]; then
291
eval setfont -v -C $console $LOADFONTS -u "$LOADFONT_MAP" $verbose
293
eval setfont -v -C $console $LOADFONTS $verbose
242
if [ ! -f "$ACM" ]; then
300
if [ ! -f "$CONSOLE_MAP" ]; then
244
302
/usr/local/share/consoletrans \
245
303
/usr/share/consoletrans \
246
304
/etc/console-setup
248
306
if [ -f "$dir/$CHARMAP.acm.gz" ]; then
249
ACM="$dir/$CHARMAP.acm.gz"
307
CONSOLE_MAP="$dir/$CHARMAP.acm.gz"
251
309
elif [ -f "$dir/$CHARMAP.acm" ]; then
252
310
ACM="$dir/$CHARMAP.acm"
257
if [ -f "$ACM" ]; then
315
if [ -f "$CONSOLE_MAP" ]; then
259
317
[ "$save" = yes ] \
260
&& [ "${ACM%/*}" != /etc/console-setup ]
318
&& [ "${CONSOLE_MAP%/*}" != /etc/console-setup ]
263
if [ "$acmdec" = "$ACM" ]; then
264
cp "$ACM" /etc/console-setup/
320
console_map_dec="${CONSOLE_MAP%.gz}"
321
if [ "$console_map_dec" = "$CONSOLE_MAP" ]; then
322
cp "$CONSOLE_MAP" /etc/console-setup/
266
gunzip -c "$ACM" >"/etc/console-setup/${acmdec##*/}"
324
gunzip -c "$CONSOLE_MAP" >"/etc/console-setup/${console_map_dec##*/}"
268
rm -f "/etc/console-setup/${acmdec##*/}.gz"
326
rm -f "/etc/console-setup/${console_map_dec##*/}.gz"
271
ACM="$CHARMAP.acm.gz"
329
CONSOLE_MAP="$CHARMAP.acm.gz"
273
if [ "$save_only" != yes ] && [ "$CHARMAP" != UTF-8 ]; then
332
[ "$save_only" != yes ] && [ "$CHARMAP" != UTF-8 ] && [ "$LOADFONTS" ]
274
334
for console in $ACTIVE_CONSOLES; do
275
335
[ -w $console ] || continue
276
336
if which consolechars >/dev/null; then
277
eval consolechars -v --tty=$console --acm "$ACM" $verbose
337
eval consolechars -v --tty=$console --acm "$CONSOLE_MAP" $verbose
278
338
elif which setfont >/dev/null; then
279
eval setfont -v -C $console -m "$ACM" $verbose
339
eval setfont -v -C $console -m "$CONSOLE_MAP" $verbose
345
[ -z "$SCREEN_WIDTH" ] || STTY="$STTY cols $SCREEN_WIDTH"
346
[ -z "$SCREEN_HEIGHT" ] || STTY="$STTY rows $SCREEN_HEIGHT"
350
for console in $ACTIVE_CONSOLES; do
351
[ -r $console ] || continue
352
stty $STTY < $console
285
357
#-----------------------#
287
359
#-----------------------#
289
if [ "$font_only" != yes ] && [ "$ACTIVE_CONSOLES" ]; then
361
if [ "$font_only" != yes ] && [ "$XKBMODEL" != unknown ] && \
362
[ "$ACTIVE_CONSOLES" ]; then
290
363
# On Mac PPC machines, we may need to set kernel vars first. We need
291
364
# to mount /proc to do that, but we need it set up before sulogin may
292
365
# be run in checkroot, which will need the keyboard to log in...
319
if which loadkeys >/dev/null; then
320
if [ "$XKBMODEL" != SKIP ] && which ckbcomp >/dev/null; then
321
if [ "$CHARMAP" != UTF-8 ]; then
322
acm_option="-charmap $CHARMAP"
327
if [ "$XKBRULES" ]; then
328
rules_option="-rules $XKBRULES"
392
if which loadkeys >/dev/null && [ "$XKBMODEL" != SKIP ]; then
393
if [ "$CHARMAP" != UTF-8 ]; then
394
acm_option="-charmap $CHARMAP"
399
if [ "$XKBRULES" ]; then
400
rules_option="-rules $XKBRULES"
406
[ "$VARIANT" = '' ] \
407
&& which gzip >/dev/null \
408
&& [ -d /usr/share/X11/xkb ] # /usr is mounted
334
[ "$VARIANT" = '' ] \
335
&& which gzip >/dev/null \
336
&& [ -d /usr/share/X11/xkb ] # /usr is mounted
411
[ ! -f /etc/console-setup/cached.kmap.gz ] \
412
|| [ /etc/console-setup/cached.kmap.gz \
413
-ot /etc/default/keyboard ] \
339
[ ! -f /etc/console-setup/cached.kmap.gz ] \
340
|| [ /etc/console-setup/cached.kmap.gz \
341
-ot /etc/default/console-setup ]
343
ckbcomp $acm_option $rules_option -model "$XKBMODEL" \
344
"$XKBLAYOUT" "$XKBVARIANT" "$XKBOPTIONS" \
345
| gzip -9 >/etc/console-setup/cached.kmap.gz
416
ckbcomp $acm_option $rules_option -model "$XKBMODEL" \
417
"$XKBLAYOUT" "$XKBVARIANT" "$XKBOPTIONS" \
418
| gzip -9 2>/dev/null >/etc/console-setup/cached.kmap.gz
419
# avoid warnings when /etc is mounted read-only
349
if [ "$save_only" != yes ]; then
423
if [ "$save_only" != yes ]; then
424
if [ "$KMAP" -a -f "$KMAP" ]; then
425
eval loadkeys "$KMAP" $verbose
351
428
[ "$VARIANT" = '' ] && [ "$CONFIG" != "$USER_CONFIG" ] \
352
429
&& [ -f /etc/console-setup/cached.kmap.gz ] \
353
430
&& [ ! /etc/console-setup/cached.kmap.gz \
354
-ot /etc/default/console-setup ]
431
-ot /etc/default/keyboard ]
356
433
eval loadkeys /etc/console-setup/cached.kmap.gz $verbose
358
ckbcomp $acm_option $rules_option -model "$XKBMODEL" \
359
"$XKBLAYOUT" "$XKBVARIANT" "$XKBOPTIONS" \
360
| eval loadkeys $verbose
435
if [ -d /usr/share/X11/xkb ]; then
436
ckbcomp $acm_option $rules_option \
438
"$XKBLAYOUT" "$XKBVARIANT" "$XKBOPTIONS" \
439
| eval loadkeys $verbose
440
elif [ -f /etc/console-setup/cached.kmap.gz ]; then
441
eval loadkeys /etc/console-setup/cached.kmap.gz $verbose
363
if which gzip >/dev/null && [ "$save" = yes ]; then
364
ckbcomp $acm_option $rules_option -model "$XKBMODEL" \
365
"$XKBLAYOUT" "$XKBVARIANT" "$XKBOPTIONS" \
366
| gzip -9 >/etc/console-setup/cached.kmap.gz
368
elif [ "$save_only" != yes ] && \
369
[ -f /etc/console-setup/cached.kmap.gz ]; then
370
eval loadkeys /etc/console-setup/cached.kmap.gz $verbose