%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/lib/dpkg/info/
Upload File :
Create Path :
Current File : /var/lib/dpkg/info/keyboard-configuration.config

#!/bin/sh

#     Copyright © 2005 Anton Zinoviev <anton@lml.bas.bg>

#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.

#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.

#     If you have not received a copy of the GNU General Public License
#     along with this program, write to the Free Software Foundation, Inc.,
#     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#                        ----------
#                         CONTENTS
#                        ----------
#
# 1. Define the auxiliary functions db_default, regex_excape,
#    regex_pattern_escape and regex_unescape.
#
# 2. Define the function all_kbdnames listing all supported keyboard
#    models, layouts and variants and a function keyboard_present
#    testing whether the computer has at least one keyboard
#
# 3. Function ask_debconf.  Ask the user to choose amongst the options
#    listed in $kbdnames.
#
# 4. Function guess_arch - detect the architecture and subarchitecture
#
# 5. Function keyboard_present - test if the computer has at least one keyboard
#
# 6. Set $locale.  Extract the strings for the chosen language in $kbdnames.
#
# 7. Compute default values for $XKBMODEL, $XKBLAYOUT, $XKBVARIANT
#    based on the architecture and the locale.
#
# 8. Overwrite (some of) the computed default values by:
#    - preseeded values (for the udeb);
#    - the value of debian-installer/keymap
#    - the contents of /etc/X11/xorg.conf
#    - the settings in the configuration files (/etc/default/...).
#    - correct some bugs of previous versions of console-setup
#
# 9. If the computer doesn't have keyboard then do not ask questions,
#    simply store the default values in the configuration file.  This
#    is in order to support headless installs in d-i.  The regular
#    packages (console-setup and console-setup-mini) should not be
#    installed on such sistems.
#
# 10. Compute default values for the Debconf questions.  For example
#     from XKBLAYOUT=us,el we obtain debconf_layout=el and from
#     XKBOPTIONS=lv3:ralt_switch we obtain debconf_altgr='Right Alt (AltGr)'
#
# 11. Ask the Debconf questions starting from STATE=1.

set -e

. /usr/share/debconf/confmodule

db_capb backup

CONFIGFILE=/etc/default/keyboard
OLDCONFIGFILE=/etc/default/console-setup

debconf_toggle=''
debconf_switch=''
debconf_altgr=''
debconf_compose=''
debconf_layout=''
debconf_variant=''
XKBMODEL=''
XKBLAYOUT=''
XKBVARIANT=''
XKBOPTIONS=''

CAPB="$RET"
detect_keyboard=false
case $CAPB in
    *plugin-detect-keyboard*)
	detect_keyboard=:
	;;
esac

if [ -f /usr/share/console-setup/keyboard-configuration.config ]; then
    is_debian_installer=yes
    is_not_debian_installer=''
else
    is_debian_installer=''
    is_not_debian_installer=yes
fi

######################################################################
#   Define auxiliary the functions db_default, regex_excape,
#   regex_pattern_escape, regex_unescape, and read_config.
######################################################################

read_config() {
    [ -r $1 ] || return 0
    . $1 || true
    # Treat missing XKBOPTIONS as empty, other vars have sane defaults:
    for var in XKBOPTIONS; do
        if ! grep "^ *${var}=" $1 >/dev/null; then
            eval ${var}=""
        fi
    done
}

which () {
    local IFS
    IFS=:
    for i in $PATH; do
	if [ -f "$i/$1" -a -x "$i/$1" ]; then
	    echo "$i/$1"
	    return 0
	fi
    done
    return 1
}

# Store default value into debconf db.  Workaround #352697.
db_default () {
    db_get keyboard-configuration/store_defaults_in_debconf_db
    if [ "$RET" = true ]; then
	db_set $1 "$2"
    fi
}

regex_escape () {
    sed \
	-e 's/[.]/%period%/g' \
	-e 's/\[/%lbracket%/g' \
	-e 's/\]/%rbracket%/g' \
	-e 's/\^/%caret%/g' \
	-e 's/\$/%dollar%/g' \
	-e 's/\\/%bslash%/g' \
	-e 's/[/]/%slash%/g' \
	-e 's/[?]/%question%/g' \
	-e 's/[+]/%plus%/g'
}

regex_pattern_escape () {
    sed \
	-e 's/[.]/%period%/g' \
	-e 's/\[/%lbracket%/g' \
	-e 's/\]/%rbracket%/g' \
	-e 's/\^/%caret%/g' \
	-e 's/\$/%dollar%/g' \
	-e 's/\\/%bslash%/g' \
	-e 's/[/]/%slash%/g' \
	-e 's/[?]/%question%/g' \
	-e 's/[+]/%plus%/g' \
	-e 's/[*]/\\*/g'
}

regex_unescape () {
    sed \
	-e 's/%period%/./g' \
	-e 's/%lbracket%/[/g' \
	-e 's/%rbracket%/]/g' \
	-e 's/%caret%/^/g' \
	-e 's/%dollar%/$/g' \
	-e 's/%bslash%/\\/g' \
	-e 's/%slash%/\//g' \
	-e 's/%question%/?/g' \
	-e 's/%plus%/+/g'
}

######################################################################
#   Define the function all_kbdnames listing all supported keyboard
#   models, layouts and variants and a function keyboard_present
#   testing whether the computer has at least one keyboard
######################################################################

all_kbdnames () {
 cat <<'EOF'
C*model*a4techKB21*A4Tech KB-21
C*model*a4techKBS8*A4Tech KBS-8
C*model*a4_rfkb23*A4Tech Wireless Desktop RFKB-23
C*model*airkey*Acer AirKey V
C*model*acer_c300*Acer C300
C*model*acer_ferrari4k*Acer Ferrari 4000
C*model*acer_laptop*Acer laptop
C*model*scorpius*Advance Scorpius KI
C*model*amiga*Amiga
C*model*apple*Apple
C*model*applealu_ansi*Apple Aluminium (ANSI)
C*model*applealu_iso*Apple Aluminium (ISO)
C*model*applealu_jis*Apple Aluminium (JIS)
C*model*asus_laptop*Asus laptop
C*model*ataritt*Atari TT
C*model*azonaRF2300*Azona RF2300 Wireless Internet
C*model*btc5090*BTC 5090
C*model*btc5113rf*BTC 5113RF Multimedia
C*model*btc5126t*BTC 5126T
C*model*btc6301urf*BTC 6301URF
C*model*btc9000*BTC 9000
C*model*btc9000a*BTC 9000A
C*model*btc9001ah*BTC 9001AH
C*model*btc9019u*BTC 9019U
C*model*btc9116u*BTC 9116U Mini Wireless Internet and Gaming
C*model*benqx*BenQ X-Touch
C*model*benqx730*BenQ X-Touch 730
C*model*benqx800*BenQ X-Touch 800
C*model*brother*Brother Internet
C*model*cherrybunlim*Cherry B.UNLIMITED
C*model*cherryblue*Cherry Blue Line CyBo@rd
C*model*cherrybluea*Cherry Blue Line CyBo@rd (alt.)
C*model*cherrycyboard*Cherry CyBo@rd USB-Hub
C*model*cherrycmexpert*Cherry CyMotion Expert
C*model*cymotionlinux*Cherry CyMotion Master Linux
C*model*cherryblueb*Cherry CyMotion Master XPress
C*model*chicony*Chicony Internet
C*model*chicony9885*Chicony KB-9885
C*model*chicony0108*Chicony KU-0108
C*model*chicony0420*Chicony KU-0420
C*model*chromebook*Chromebook
C*model*classmate*Classmate PC
C*model*compalfl90*Compal FL90
C*model*armada*Compaq Armada laptop
C*model*compaqeak8*Compaq Easy Access
C*model*compaqik13*Compaq Internet (13 keys)
C*model*compaqik18*Compaq Internet (18 keys)
C*model*compaqik7*Compaq Internet (7 keys)
C*model*presario*Compaq Presario laptop
C*model*ipaq*Compaq iPaq
C*model*creativedw7000*Creative Desktop Wireless 7000
C*model*dtk2000*DTK2000
C*model*dell*Dell
C*model*dell101*Dell 101-key PC
C*model*inspiron*Dell Inspiron 6000/8000 laptop
C*model*latitude*Dell Latitude laptop
C*model*precision_m*Dell Precision M laptop
C*model*dellm65*Dell Precision M65 laptop
C*model*dellsk8125*Dell SK-8125
C*model*dellsk8135*Dell SK-8135
C*model*dellusbmm*Dell USB Multimedia
C*model*dexxa*Dexxa Wireless Desktop
C*model*diamond*Diamond 9801/9802
C*model*SKIP*Do not configure keyboard; keep kernel keymap
C*model*ennyah_dkb1008*Ennyah DKB-1008
C*model*everex*Everex STEPnote
C*model*fscaa1667g*Fujitsu-Siemens Amilo laptop
C*model*pc101*Generic 101-key PC
C*model*pc102*Generic 102-key PC
C*model*pc104*Generic 104-key PC
C*model*pc104alt*Generic 104-key PC with L-shaped Enter key
C*model*pc105*Generic 105-key PC
C*model*pc86*Generic 86-key PC
C*model*geniuscomfy*Genius Comfy KB-12e
C*model*genius*Genius Comfy KB-16M/Multimedia KWD-910
C*model*geniuscomfy2*Genius Comfy KB-21e-Scroll
C*model*geniuskb19e*Genius KB-19e NB
C*model*geniuskkb2050hs*Genius KKB-2050HS
C*model*gyration*Gyration
C*model*hhk*Happy Hacking
C*model*macintosh_hhk*Happy Hacking for Mac
C*model*hpi6*Hewlett-Packard Internet
C*model*hpmini110*Hewlett-Packard Mini 110 laptop
C*model*hp5xx*Hewlett-Packard Omnibook 500
C*model*hp500fa*Hewlett-Packard Omnibook 500 FA
C*model*hp6000*Hewlett-Packard Omnibook 6000/6100
C*model*hpxe3gc*Hewlett-Packard Omnibook XE3 GC
C*model*hpxe3gf*Hewlett-Packard Omnibook XE3 GF
C*model*hpxt1000*Hewlett-Packard Omnibook XT1000
C*model*hpzt11xx*Hewlett-Packard Pavilion ZT1100
C*model*hpdv5*Hewlett-Packard Pavilion dv5
C*model*hp250x*Hewlett-Packard SK-2501 Multimedia
C*model*hpnx9020*Hewlett-Packard nx9020
C*model*honeywell_euroboard*Honeywell Euroboard
C*model*rapidaccess*IBM Rapid Access
C*model*rapidaccess2*IBM Rapid Access II
C*model*ibm_spacesaver*IBM Space Saver
C*model*thinkpad*IBM ThinkPad 560Z/600/600E/A22E
C*model*thinkpad60*IBM ThinkPad R60/T60/R61/T61
C*model*thinkpadz60*IBM ThinkPad Z60m/Z60t/Z61m/Z61t
C*model*flexpro*Keytronic FlexPro
C*model*kinesis*Kinesis
C*model*logitech_base*Logitech
C*model*logiaccess*Logitech Access
C*model*logicd*Logitech Cordless Desktop
C*model*logicda*Logitech Cordless Desktop (alt.)
C*model*logiex110*Logitech Cordless Desktop EX110
C*model*logiclx300*Logitech Cordless Desktop LX-300
C*model*logicd_nav*Logitech Cordless Desktop Navigator
C*model*logicd_opt*Logitech Cordless Desktop Optical
C*model*logicd_it*Logitech Cordless Desktop iTouch
C*model*logitech_g15*Logitech G15 extra keys via G15daemon
C*model*logiik*Logitech Internet
C*model*logimel*Logitech Internet 350
C*model*logicink*Logitech Internet Navigator
C*model*logiultrax*Logitech Ultra-X
C*model*logiultraxc*Logitech Ultra-X Cordless Media Desktop
C*model*logidinovo*Logitech diNovo
C*model*logidinovoedge*Logitech diNovo Edge
C*model*itouch*Logitech iTouch
C*model*logiitc*Logitech iTouch Cordless Y-RB6
C*model*logiinkse*Logitech iTouch Internet Navigator SE
C*model*logiinkseusb*Logitech iTouch Internet Navigator SE USB
C*model*macbook78*MacBook/MacBook Pro
C*model*macbook79*MacBook/MacBook Pro (intl.)
C*model*macintosh*Macintosh
C*model*macintosh_old*Macintosh Old
C*model*mx1998*Memorex MX1998
C*model*mx2500*Memorex MX2500 EZ-Access
C*model*mx2750*Memorex MX2750
C*model*microsoftccurve2k*Microsoft Comfort Curve 2000
C*model*microsoftinet*Microsoft Internet
C*model*microsoftprose*Microsoft Internet Pro (Swedish)
C*model*microsoft*Microsoft Natural
C*model*microsoftelite*Microsoft Natural Elite
C*model*microsoft4000*Microsoft Natural Ergonomic 4000
C*model*microsoftprooem*Microsoft Natural Pro OEM
C*model*microsoftprousb*Microsoft Natural Pro USB/Internet Pro
C*model*microsoftpro*Microsoft Natural Pro/Internet Pro
C*model*microsoft7000*Microsoft Natural Wireless Ergonomic 7000
C*model*microsoftoffice*Microsoft Office Keyboard
C*model*microsoftsurface*Microsoft Surface
C*model*microsoftmult*Microsoft Wireless Multimedia 1.0A
C*model*sk1300*NEC SK-1300
C*model*sk2500*NEC SK-2500
C*model*sk6200*NEC SK-6200
C*model*sk7100*NEC SK-7100
C*model*omnikey101*Northgate OmniKey 101
C*model*olpc*OLPC
C*model*oretec*Ortek Multimedia/Internet MCK-800
C*model*pc98*PC-98
C*model*ppkb*PinePhone Keyboard
C*model*propeller*Propeller Voyager KTEZ-1000
C*model*qtronix*QTronix Scorpius 98N+
C*model*sven*SVEN Ergonomic 2500
C*model*sven303*SVEN Slim 303
C*model*samsung4500*Samsung SDM 4500P
C*model*samsung4510*Samsung SDM 4510P
C*model*sanwaskbkg3*Sanwa Supply SKB-KG3
C*model*silvercrest*Silvercrest Multimedia Wireless
C*model*apex300*SteelSeries Apex 300 (Apex RAW)
C*model*sun4*Sun Type 4
C*model*sun5*Sun Type 5
C*model*sun_type6_jp*Sun Type 6 (Japanese)
C*model*sun_type6_jp_usb*Sun Type 6 USB (Japanese)
C*model*sun_type6_unix_usb*Sun Type 6 USB (Unix)
C*model*sun_type6_usb*Sun Type 6/7 USB
C*model*sun_type6_euro_usb*Sun Type 6/7 USB (European)
C*model*sun_type7_usb*Sun Type 7 USB
C*model*sun_type7_euro_usb*Sun Type 7 USB (European)
C*model*sun_type7_jp_usb*Sun Type 7 USB (Japanese)/Japanese 106-key
C*model*sun_type7_unix_usb*Sun Type 7 USB (Unix)
C*model*sp_inet*Super Power Multimedia
C*model*symplon*Symplon PaceBook tablet
C*model*targa_v811*Targa Visionary 811
C*model*toshiba_s3000*Toshiba Satellite S3000
C*model*teck227*Truly Ergonomic 227
C*model*teck229*Truly Ergonomic 229
C*model*trustda*Trust Direct Access
C*model*trust_slimline*Trust Slimline
C*model*trust*Trust Wireless Classic
C*model*tm2020*TypeMatrix EZ-Reach 2020
C*model*tm2030PS2*TypeMatrix EZ-Reach 2030 PS2
C*model*tm2030USB*TypeMatrix EZ-Reach 2030 USB
C*model*tm2030USB-102*TypeMatrix EZ-Reach 2030 USB (102/105:EU mode)
C*model*tm2030USB-106*TypeMatrix EZ-Reach 2030 USB (106:JP mode)
C*model*unitekkb1925*Unitek KB-1925
C*model*vsonku306*ViewSonic KU-306 Internet
C*model*winbook*Winbook Model XP5
C*model*yahoo*Yahoo! Internet
C*model*emachines*eMachines m6800 laptop
C*layout*custom*A user-defined custom Layout
C*variant*custom**A user-defined custom Layout
C*layout*al*Albanian
C*variant*al**Albanian
C*variant*al*plisi*Albanian - Albanian (Plisi)
C*variant*al*veqilharxhi*Albanian - Albanian (Veqilharxhi)
C*layout*et*Amharic
C*variant*et**Amharic
C*layout*ara*Arabic
C*variant*ara**Arabic
C*variant*ara*azerty*Arabic - Arabic (AZERTY)
C*variant*ara*azerty_digits*Arabic - Arabic (AZERTY, Eastern Arabic numerals)
C*variant*ara*buckwalter*Arabic - Arabic (Buckwalter)
C*variant*ara*digits*Arabic - Arabic (Eastern Arabic numerals)
C*variant*ara*mac*Arabic - Arabic (Macintosh)
C*variant*ara*mac-phonetic*Arabic - Arabic (Macintosh, phonetic)
C*variant*ara*olpc*Arabic - Arabic (OLPC)
C*layout*eg*Arabic (Egypt)
C*variant*eg**Arabic (Egypt)
C*layout*iq*Arabic (Iraq)
C*variant*iq**Arabic (Iraq)
C*variant*iq*ku_ara*Arabic (Iraq) - Kurdish (Iraq, Arabic-Latin)
C*variant*iq*ku_f*Arabic (Iraq) - Kurdish (Iraq, F)
C*variant*iq*ku_alt*Arabic (Iraq) - Kurdish (Iraq, Latin Alt-Q)
C*variant*iq*ku*Arabic (Iraq) - Kurdish (Iraq, Latin Q)
C*layout*ma*Arabic (Morocco)
C*variant*ma**Arabic (Morocco)
C*variant*ma*tifinagh-alt*Arabic (Morocco) - Berber (Morocco, Tifinagh alt.)
C*variant*ma*tifinagh-extended-phonetic*Arabic (Morocco) - Berber (Morocco, Tifinagh extended phonetic)
C*variant*ma*tifinagh-extended*Arabic (Morocco) - Berber (Morocco, Tifinagh extended)
C*variant*ma*tifinagh-phonetic*Arabic (Morocco) - Berber (Morocco, Tifinagh phonetic)
C*variant*ma*tifinagh-alt-phonetic*Arabic (Morocco) - Berber (Morocco, Tifinagh phonetic, alt.)
C*variant*ma*tifinagh*Arabic (Morocco) - Berber (Morocco, Tifinagh)
C*variant*ma*french*Arabic (Morocco) - French (Morocco)
C*variant*ma*rif*Arabic (Morocco) - Tarifit
C*layout*sy*Arabic (Syria)
C*variant*sy**Arabic (Syria)
C*variant*sy*ku_f*Arabic (Syria) - Kurdish (Syria, F)
C*variant*sy*ku_alt*Arabic (Syria) - Kurdish (Syria, Latin Alt-Q)
C*variant*sy*ku*Arabic (Syria) - Kurdish (Syria, Latin Q)
C*variant*sy*syc*Arabic (Syria) - Syriac
C*variant*sy*syc_phonetic*Arabic (Syria) - Syriac (phonetic)
C*layout*am*Armenian
C*variant*am**Armenian
C*variant*am*eastern-alt*Armenian - Armenian (alt. eastern)
C*variant*am*phonetic-alt*Armenian - Armenian (alt. phonetic)
C*variant*am*eastern*Armenian - Armenian (eastern)
C*variant*am*phonetic*Armenian - Armenian (phonetic)
C*variant*am*western*Armenian - Armenian (western)
C*layout*az*Azerbaijani
C*variant*az**Azerbaijani
C*variant*az*cyrillic*Azerbaijani - Azerbaijani (Cyrillic)
C*layout*ml*Bambara
C*variant*ml**Bambara
C*variant*ml*us-mac*Bambara - English (Mali, US, Macintosh)
C*variant*ml*us-intl*Bambara - English (Mali, US, intl.)
C*variant*ml*fr-oss*Bambara - French (Mali, alt.)
C*layout*bd*Bangla
C*variant*bd**Bangla
C*variant*bd*probhat*Bangla - Bangla (Probhat)
C*layout*by*Belarusian
C*variant*by**Belarusian
C*variant*by*latin*Belarusian - Belarusian (Latin)
C*variant*by*intl*Belarusian - Belarusian (intl.)
C*variant*by*legacy*Belarusian - Belarusian (legacy)
C*variant*by*phonetic*Belarusian - Belarusian (phonetic)
C*variant*by*ru*Belarusian - Russian (Belarus)
C*layout*be*Belgian
C*variant*be**Belgian
C*variant*be*iso-alternate*Belgian - Belgian (ISO, alt.)
C*variant*be*oss_latin9*Belgian - Belgian (Latin-9 only, alt.)
C*variant*be*wang*Belgian - Belgian (Wang 724 AZERTY)
C*variant*be*oss*Belgian - Belgian (alt.)
C*variant*be*nodeadkeys*Belgian - Belgian (no dead keys)
C*layout*dz*Berber (Algeria, Latin)
C*variant*dz**Berber (Algeria, Latin)
C*variant*dz*ar*Berber (Algeria, Latin) - Arabic (Algeria)
C*variant*dz*ber*Berber (Algeria, Latin) - Berber (Algeria, Tifinagh)
C*variant*dz*azerty-deadkeys*Berber (Algeria, Latin) - Kabyle (AZERTY, with dead keys)
C*variant*dz*qwerty-gb-deadkeys*Berber (Algeria, Latin) - Kabyle (QWERTY, UK, with dead keys)
C*variant*dz*qwerty-us-deadkeys*Berber (Algeria, Latin) - Kabyle (QWERTY, US, with dead keys)
C*layout*ba*Bosnian
C*variant*ba**Bosnian
C*variant*ba*us*Bosnian - Bosnian (US)
C*variant*ba*unicodeus*Bosnian - Bosnian (US, with Bosnian digraphs)
C*variant*ba*unicode*Bosnian - Bosnian (with Bosnian digraphs)
C*variant*ba*alternatequotes*Bosnian - Bosnian (with guillemets)
C*layout*brai*Braille
C*variant*brai**Braille
C*variant*brai*left_hand_invert*Braille - Braille (left-handed inverted thumb)
C*variant*brai*left_hand*Braille - Braille (left-handed)
C*variant*brai*right_hand_invert*Braille - Braille (right-handed inverted thumb)
C*variant*brai*right_hand*Braille - Braille (right-handed)
C*layout*bg*Bulgarian
C*variant*bg**Bulgarian
C*variant*bg*bekl*Bulgarian - Bulgarian (enhanced)
C*variant*bg*bas_phonetic*Bulgarian - Bulgarian (new phonetic)
C*variant*bg*phonetic*Bulgarian - Bulgarian (traditional phonetic)
C*layout*mm*Burmese
C*variant*mm**Burmese
C*variant*mm*zawgyi*Burmese - Burmese (Zawgyi)
C*variant*mm*mnw*Burmese - Mon
C*variant*mm*mnw-a1*Burmese - Mon (A1)
C*variant*mm*shn*Burmese - Shan
C*variant*mm*zgt*Burmese - Shan (Zawgyi)
C*layout*cn*Chinese
C*variant*cn**Chinese
C*variant*cn*altgr-pinyin*Chinese - Hanyu Pinyin Letters (with AltGr dead keys)
C*variant*cn*mon_trad*Chinese - Mongolian (Bichig)
C*variant*cn*mon_trad_galik*Chinese - Mongolian (Galik)
C*variant*cn*mon_manchu_galik*Chinese - Mongolian (Manchu Galik)
C*variant*cn*mon_trad_manchu*Chinese - Mongolian (Manchu)
C*variant*cn*mon_todo_galik*Chinese - Mongolian (Todo Galik)
C*variant*cn*mon_trad_todo*Chinese - Mongolian (Todo)
C*variant*cn*mon_trad_xibe*Chinese - Mongolian (Xibe)
C*variant*cn*tib*Chinese - Tibetan
C*variant*cn*tib_asciinum*Chinese - Tibetan (with ASCII numerals)
C*variant*cn*ug*Chinese - Uyghur
C*layout*hr*Croatian
C*variant*hr**Croatian
C*variant*hr*us*Croatian - Croatian (US)
C*variant*hr*unicodeus*Croatian - Croatian (US, with Croatian digraphs)
C*variant*hr*unicode*Croatian - Croatian (with Croatian digraphs)
C*variant*hr*alternatequotes*Croatian - Croatian (with guillemets)
C*layout*cz*Czech
C*variant*cz**Czech
C*variant*cz*qwerty*Czech - Czech (QWERTY)
C*variant*cz*qwerty-mac*Czech - Czech (QWERTY, Macintosh)
C*variant*cz*winkeys-qwerty*Czech - Czech (QWERTY, Windows)
C*variant*cz*qwerty_bksl*Czech - Czech (QWERTY, extra backslash)
C*variant*cz*winkeys*Czech - Czech (QWERTZ, Windows)
C*variant*cz*ucw*Czech - Czech (UCW, only accented letters)
C*variant*cz*dvorak-ucw*Czech - Czech (US, Dvorak, UCW support)
C*variant*cz*bksl*Czech - Czech (extra backslash)
C*variant*cz*rus*Czech - Russian (Czechia, phonetic)
C*layout*dk*Danish
C*variant*dk**Danish
C*variant*dk*dvorak*Danish - Danish (Dvorak)
C*variant*dk*mac*Danish - Danish (Macintosh)
C*variant*dk*mac_nodeadkeys*Danish - Danish (Macintosh, no dead keys)
C*variant*dk*winkeys*Danish - Danish (Windows)
C*variant*dk*nodeadkeys*Danish - Danish (no dead keys)
C*layout*af*Dari
C*variant*af**Dari
C*variant*af*fa-olpc*Dari - Dari (Afghanistan, OLPC)
C*variant*af*ps*Dari - Pashto
C*variant*af*ps-olpc*Dari - Pashto (Afghanistan, OLPC)
C*variant*af*uz*Dari - Uzbek (Afghanistan)
C*variant*af*uz-olpc*Dari - Uzbek (Afghanistan, OLPC)
C*layout*mv*Dhivehi
C*variant*mv**Dhivehi
C*layout*nl*Dutch
C*variant*nl**Dutch
C*variant*nl*mac*Dutch - Dutch (Macintosh)
C*variant*nl*us*Dutch - Dutch (US)
C*variant*nl*std*Dutch - Dutch (standard)
C*layout*bt*Dzongkha
C*variant*bt**Dzongkha
C*layout*au*English (Australia)
C*variant*au**English (Australia)
C*layout*cm*English (Cameroon)
C*variant*cm**English (Cameroon)
C*variant*cm*azerty*English (Cameroon) - Cameroon (AZERTY, intl.)
C*variant*cm*dvorak*English (Cameroon) - Cameroon (Dvorak, intl.)
C*variant*cm*qwerty*English (Cameroon) - Cameroon Multilingual (QWERTY, intl.)
C*variant*cm*french*English (Cameroon) - French (Cameroon)
C*variant*cm*mmuock*English (Cameroon) - Mmuock
C*layout*gh*English (Ghana)
C*variant*gh**English (Ghana)
C*variant*gh*akan*English (Ghana) - Akan
C*variant*gh*avn*English (Ghana) - Avatime
C*variant*gh*gillbt*English (Ghana) - English (Ghana, GILLBT)
C*variant*gh*generic*English (Ghana) - English (Ghana, multilingual)
C*variant*gh*ewe*English (Ghana) - Ewe
C*variant*gh*fula*English (Ghana) - Fula
C*variant*gh*ga*English (Ghana) - Ga
C*variant*gh*hausa*English (Ghana) - Hausa (Ghana)
C*layout*nz*English (New Zealand)
C*variant*nz**English (New Zealand)
C*variant*nz*mao*English (New Zealand) - Maori
C*layout*ng*English (Nigeria)
C*variant*ng**English (Nigeria)
C*variant*ng*hausa*English (Nigeria) - Hausa (Nigeria)
C*variant*ng*igbo*English (Nigeria) - Igbo
C*variant*ng*yoruba*English (Nigeria) - Yoruba
C*layout*za*English (South Africa)
C*variant*za**English (South Africa)
C*layout*gb*English (UK)
C*variant*gb**English (UK)
C*variant*gb*colemak*English (UK) - English (UK, Colemak)
C*variant*gb*colemak_dh*English (UK) - English (UK, Colemak-DH)
C*variant*gb*dvorak*English (UK) - English (UK, Dvorak)
C*variant*gb*dvorakukp*English (UK) - English (UK, Dvorak, with UK punctuation)
C*variant*gb*mac*English (UK) - English (UK, Macintosh)
C*variant*gb*mac_intl*English (UK) - English (UK, Macintosh, intl.)
C*variant*gb*extd*English (UK) - English (UK, extended, Windows)
C*variant*gb*intl*English (UK) - English (UK, intl., with dead keys)
C*variant*gb*pl*English (UK) - Polish (British keyboard)
C*variant*gb*gla*English (UK) - Scottish Gaelic
C*layout*us*English (US)
C*variant*us**English (US)
C*variant*us*chr*English (US) - Cherokee
C*variant*us*colemak*English (US) - English (Colemak)
C*variant*us*colemak_dh_iso*English (US) - English (Colemak-DH ISO)
C*variant*us*colemak_dh_ortho*English (US) - English (Colemak-DH Ortholinear)
C*variant*us*colemak_dh_wide_iso*English (US) - English (Colemak-DH Wide ISO)
C*variant*us*colemak_dh_wide*English (US) - English (Colemak-DH Wide)
C*variant*us*colemak_dh*English (US) - English (Colemak-DH)
C*variant*us*dvorak*English (US) - English (Dvorak)
C*variant*us*dvorak-mac*English (US) - English (Dvorak, Macintosh)
C*variant*us*dvorak-alt-intl*English (US) - English (Dvorak, alt. intl.)
C*variant*us*dvorak-intl*English (US) - English (Dvorak, intl., with dead keys)
C*variant*us*dvorak-l*English (US) - English (Dvorak, left-handed)
C*variant*us*dvorak-r*English (US) - English (Dvorak, right-handed)
C*variant*us*mac*English (US) - English (Macintosh)
C*variant*us*norman*English (US) - English (Norman)
C*variant*us*symbolic*English (US) - English (US, Symbolic)
C*variant*us*alt-intl*English (US) - English (US, alt. intl.)
C*variant*us*euro*English (US) - English (US, euro on 5)
C*variant*us*intl*English (US) - English (US, intl., with dead keys)
C*variant*us*workman*English (US) - English (Workman)
C*variant*us*workman-intl*English (US) - English (Workman, intl., with dead keys)
C*variant*us*dvorak-classic*English (US) - English (classic Dvorak)
C*variant*us*altgr-intl*English (US) - English (intl., with AltGr dead keys)
C*variant*us*dvp*English (US) - English (programmer Dvorak)
C*variant*us*olpc2*English (US) - English (the divide/multiply toggle the layout)
C*variant*us*haw*English (US) - Hawaiian
C*variant*us*rus*English (US) - Russian (US, phonetic)
C*variant*us*hbs*English (US) - Serbo-Croatian (US)
C*layout*epo*Esperanto
C*variant*epo**Esperanto
C*variant*epo*legacy*Esperanto - Esperanto (legacy)
C*layout*ee*Estonian
C*variant*ee**Estonian
C*variant*ee*dvorak*Estonian - Estonian (Dvorak)
C*variant*ee*us*Estonian - Estonian (US)
C*variant*ee*nodeadkeys*Estonian - Estonian (no dead keys)
C*layout*fo*Faroese
C*variant*fo**Faroese
C*variant*fo*nodeadkeys*Faroese - Faroese (no dead keys)
C*layout*ph*Filipino
C*variant*ph**Filipino
C*variant*ph*capewell-dvorak-bay*Filipino - Filipino (Capewell-Dvorak, Baybayin)
C*variant*ph*capewell-dvorak*Filipino - Filipino (Capewell-Dvorak, Latin)
C*variant*ph*capewell-qwerf2k6-bay*Filipino - Filipino (Capewell-QWERF 2006, Baybayin)
C*variant*ph*capewell-qwerf2k6*Filipino - Filipino (Capewell-QWERF 2006, Latin)
C*variant*ph*colemak-bay*Filipino - Filipino (Colemak, Baybayin)
C*variant*ph*colemak*Filipino - Filipino (Colemak, Latin)
C*variant*ph*dvorak-bay*Filipino - Filipino (Dvorak, Baybayin)
C*variant*ph*dvorak*Filipino - Filipino (Dvorak, Latin)
C*variant*ph*qwerty-bay*Filipino - Filipino (QWERTY, Baybayin)
C*layout*fi*Finnish
C*variant*fi**Finnish
C*variant*fi*mac*Finnish - Finnish (Macintosh)
C*variant*fi*winkeys*Finnish - Finnish (Windows)
C*variant*fi*classic*Finnish - Finnish (classic)
C*variant*fi*nodeadkeys*Finnish - Finnish (classic, no dead keys)
C*variant*fi*smi*Finnish - Northern Saami (Finland)
C*layout*fr*French
C*variant*fr**French
C*variant*fr*bre*French - Breton (France)
C*variant*fr*azerty*French - French (AZERTY)
C*variant*fr*afnor*French - French (AZERTY, AFNOR)
C*variant*fr*bepo*French - French (BEPO)
C*variant*fr*bepo_afnor*French - French (BEPO, AFNOR)
C*variant*fr*bepo_latin9*French - French (BEPO, Latin-9 only)
C*variant*fr*dvorak*French - French (Dvorak)
C*variant*fr*mac*French - French (Macintosh)
C*variant*fr*us*French - French (US)
C*variant*fr*oss*French - French (alt.)
C*variant*fr*oss_latin9*French - French (alt., Latin-9 only)
C*variant*fr*oss_nodeadkeys*French - French (alt., no dead keys)
C*variant*fr*latin9*French - French (legacy, alt.)
C*variant*fr*latin9_nodeadkeys*French - French (legacy, alt., no dead keys)
C*variant*fr*nodeadkeys*French - French (no dead keys)
C*variant*fr*geo*French - Georgian (France, AZERTY Tskapo)
C*variant*fr*oci*French - Occitan
C*layout*ca*French (Canada)
C*variant*ca**French (Canada)
C*variant*ca*multix*French (Canada) - Canadian (CSA)
C*variant*ca*eng*French (Canada) - English (Canada)
C*variant*ca*fr-dvorak*French (Canada) - French (Canada, Dvorak)
C*variant*ca*fr-legacy*French (Canada) - French (Canada, legacy)
C*variant*ca*ike*French (Canada) - Inuktitut
C*layout*cd*French (Democratic Republic of the Congo)
C*variant*cd**French (Democratic Republic of the Congo)
C*layout*tg*French (Togo)
C*variant*tg**French (Togo)
C*layout*ge*Georgian
C*variant*ge**Georgian
C*variant*ge*mess*Georgian - Georgian (MESS)
C*variant*ge*ergonomic*Georgian - Georgian (ergonomic)
C*variant*ge*os*Georgian - Ossetian (Georgia)
C*variant*ge*ru*Georgian - Russian (Georgia)
C*layout*de*German
C*variant*de**German
C*variant*de*dvorak*German - German (Dvorak)
C*variant*de*e1*German - German (E1)
C*variant*de*e2*German - German (E2)
C*variant*de*mac*German - German (Macintosh)
C*variant*de*mac_nodeadkeys*German - German (Macintosh, no dead keys)
C*variant*de*neo*German - German (Neo 2)
C*variant*de*qwerty*German - German (QWERTY)
C*variant*de*T3*German - German (T3)
C*variant*de*us*German - German (US)
C*variant*de*deadacute*German - German (dead acute)
C*variant*de*deadgraveacute*German - German (dead grave acute)
C*variant*de*deadtilde*German - German (dead tilde)
C*variant*de*nodeadkeys*German - German (no dead keys)
C*variant*de*dsb*German - Lower Sorbian
C*variant*de*dsb_qwertz*German - Lower Sorbian (QWERTZ)
C*variant*de*ro*German - Romanian (Germany)
C*variant*de*ro_nodeadkeys*German - Romanian (Germany, no dead keys)
C*variant*de*ru*German - Russian (Germany, phonetic)
C*variant*de*tr*German - Turkish (Germany)
C*layout*at*German (Austria)
C*variant*at**German (Austria)
C*variant*at*mac*German (Austria) - German (Austria, Macintosh)
C*variant*at*nodeadkeys*German (Austria) - German (Austria, no dead keys)
C*layout*gr*Greek
C*variant*gr**Greek
C*variant*gr*nodeadkeys*Greek - Greek (no dead keys)
C*variant*gr*polytonic*Greek - Greek (polytonic)
C*variant*gr*simple*Greek - Greek (simple)
C*layout*il*Hebrew
C*variant*il**Hebrew
C*variant*il*biblical*Hebrew - Hebrew (Biblical, Tiro)
C*variant*il*si2*Hebrew - Hebrew (SI-1452-2)
C*variant*il*lyx*Hebrew - Hebrew (lyx)
C*variant*il*phonetic*Hebrew - Hebrew (phonetic)
C*layout*hu*Hungarian
C*variant*hu**Hungarian
C*variant*hu*qwerty*Hungarian - Hungarian (QWERTY)
C*variant*hu*101_qwerty_comma_dead*Hungarian - Hungarian (QWERTY, 101-key, comma, dead keys)
C*variant*hu*101_qwerty_comma_nodead*Hungarian - Hungarian (QWERTY, 101-key, comma, no dead keys)
C*variant*hu*101_qwerty_dot_dead*Hungarian - Hungarian (QWERTY, 101-key, dot, dead keys)
C*variant*hu*101_qwerty_dot_nodead*Hungarian - Hungarian (QWERTY, 101-key, dot, no dead keys)
C*variant*hu*102_qwerty_comma_dead*Hungarian - Hungarian (QWERTY, 102-key, comma, dead keys)
C*variant*hu*102_qwerty_comma_nodead*Hungarian - Hungarian (QWERTY, 102-key, comma, no dead keys)
C*variant*hu*102_qwerty_dot_dead*Hungarian - Hungarian (QWERTY, 102-key, dot, dead keys)
C*variant*hu*102_qwerty_dot_nodead*Hungarian - Hungarian (QWERTY, 102-key, dot, no dead keys)
C*variant*hu*101_qwertz_comma_dead*Hungarian - Hungarian (QWERTZ, 101-key, comma, dead keys)
C*variant*hu*101_qwertz_comma_nodead*Hungarian - Hungarian (QWERTZ, 101-key, comma, no dead keys)
C*variant*hu*101_qwertz_dot_dead*Hungarian - Hungarian (QWERTZ, 101-key, dot, dead keys)
C*variant*hu*101_qwertz_dot_nodead*Hungarian - Hungarian (QWERTZ, 101-key, dot, no dead keys)
C*variant*hu*102_qwertz_comma_dead*Hungarian - Hungarian (QWERTZ, 102-key, comma, dead keys)
C*variant*hu*102_qwertz_comma_nodead*Hungarian - Hungarian (QWERTZ, 102-key, comma, no dead keys)
C*variant*hu*102_qwertz_dot_dead*Hungarian - Hungarian (QWERTZ, 102-key, dot, dead keys)
C*variant*hu*102_qwertz_dot_nodead*Hungarian - Hungarian (QWERTZ, 102-key, dot, no dead keys)
C*variant*hu*nodeadkeys*Hungarian - Hungarian (no dead keys)
C*variant*hu*standard*Hungarian - Hungarian (standard)
C*layout*is*Icelandic
C*variant*is**Icelandic
C*variant*is*dvorak*Icelandic - Icelandic (Dvorak)
C*variant*is*mac*Icelandic - Icelandic (Macintosh)
C*variant*is*mac_legacy*Icelandic - Icelandic (Macintosh, legacy)
C*layout*in*Indian
C*variant*in**Indian
C*variant*in*asm-kagapa*Indian - Assamese (KaGaPa, phonetic)
C*variant*in*ben*Indian - Bangla (India)
C*variant*in*ben_inscript*Indian - Bangla (India, Baishakhi InScript)
C*variant*in*ben_baishakhi*Indian - Bangla (India, Baishakhi)
C*variant*in*ben_bornona*Indian - Bangla (India, Bornona)
C*variant*in*ben_gitanjali*Indian - Bangla (India, Gitanjali)
C*variant*in*ben-kagapa*Indian - Bangla (India, KaGaPa, phonetic)
C*variant*in*ben_probhat*Indian - Bangla (India, Probhat)
C*variant*in*eng*Indian - English (India, with rupee)
C*variant*in*guj*Indian - Gujarati
C*variant*in*guj-kagapa*Indian - Gujarati (KaGaPa, phonetic)
C*variant*in*bolnagri*Indian - Hindi (Bolnagri)
C*variant*in*hin-kagapa*Indian - Hindi (KaGaPa, phonetic)
C*variant*in*hin-wx*Indian - Hindi (Wx)
C*variant*in*iipa*Indian - Indic IPA
C*variant*in*kan*Indian - Kannada
C*variant*in*kan-kagapa*Indian - Kannada (KaGaPa, phonetic)
C*variant*in*mal*Indian - Malayalam
C*variant*in*mal_lalitha*Indian - Malayalam (Lalitha)
C*variant*in*mal_poorna*Indian - Malayalam (Poorna, extended InScript)
C*variant*in*mal_enhanced*Indian - Malayalam (enhanced InScript, with rupee)
C*variant*in*mni*Indian - Manipuri (Meitei)
C*variant*in*mar-kagapa*Indian - Marathi (KaGaPa, phonetic)
C*variant*in*marathi*Indian - Marathi (enhanced InScript)
C*variant*in*ori*Indian - Oriya
C*variant*in*ori-bolnagri*Indian - Oriya (Bolnagri)
C*variant*in*ori-wx*Indian - Oriya (Wx)
C*variant*in*jhelum*Indian - Punjabi (Gurmukhi Jhelum)
C*variant*in*guru*Indian - Punjabi (Gurmukhi)
C*variant*in*san-kagapa*Indian - Sanskrit (KaGaPa, phonetic)
C*variant*in*sat*Indian - Santali (Ol Chiki)
C*variant*in*tam*Indian - Tamil (InScript, with Arabic numerals)
C*variant*in*tam_tamilnumbers*Indian - Tamil (InScript, with Tamil numerals)
C*variant*in*tamilnet_tamilnumbers*Indian - Tamil (TamilNet 99 with Tamil numerals)
C*variant*in*tamilnet*Indian - Tamil (TamilNet 99)
C*variant*in*tamilnet_TAB*Indian - Tamil (TamilNet 99, TAB encoding)
C*variant*in*tamilnet_TSCII*Indian - Tamil (TamilNet 99, TSCII encoding)
C*variant*in*tel*Indian - Telugu
C*variant*in*tel-kagapa*Indian - Telugu (KaGaPa, phonetic)
C*variant*in*tel-sarala*Indian - Telugu (Sarala)
C*variant*in*urd-winkeys*Indian - Urdu (Windows)
C*variant*in*urd-phonetic3*Indian - Urdu (alt. phonetic)
C*variant*in*urd-phonetic*Indian - Urdu (phonetic)
C*layout*id*Indonesian (Latin)
C*variant*id**Indonesian (Latin)
C*variant*id*melayu-phoneticx*Indonesian (Latin) - Indonesian (Arab Melayu, extended phonetic)
C*variant*id*melayu-phonetic*Indonesian (Latin) - Indonesian (Arab Melayu, phonetic)
C*variant*id*pegon-phonetic*Indonesian (Latin) - Indonesian (Arab Pegon, phonetic)
C*variant*id*javanese*Indonesian (Latin) - Javanese
C*layout*ie*Irish
C*variant*ie**Irish
C*variant*ie*CloGaelach*Irish - CloGaelach
C*variant*ie*UnicodeExpert*Irish - Irish (UnicodeExpert)
C*variant*ie*ogam*Irish - Ogham
C*variant*ie*ogam_is434*Irish - Ogham (IS434)
C*layout*it*Italian
C*variant*it**Italian
C*variant*it*fur*Italian - Friulian (Italy)
C*variant*it*geo*Italian - Georgian (Italy)
C*variant*it*ibm*Italian - Italian (IBM 142)
C*variant*it*mac*Italian - Italian (Macintosh)
C*variant*it*us*Italian - Italian (US)
C*variant*it*winkeys*Italian - Italian (Windows)
C*variant*it*nodeadkeys*Italian - Italian (no dead keys)
C*variant*it*scn*Italian - Sicilian
C*layout*jp*Japanese
C*variant*jp**Japanese
C*variant*jp*dvorak*Japanese - Japanese (Dvorak)
C*variant*jp*kana86*Japanese - Japanese (Kana 86)
C*variant*jp*kana*Japanese - Japanese (Kana)
C*variant*jp*mac*Japanese - Japanese (Macintosh)
C*variant*jp*OADG109A*Japanese - Japanese (OADG 109A)
C*layout*kz*Kazakh
C*variant*kz**Kazakh
C*variant*kz*latin*Kazakh - Kazakh (Latin)
C*variant*kz*ext*Kazakh - Kazakh (extended)
C*variant*kz*kazrus*Kazakh - Kazakh (with Russian)
C*variant*kz*ruskaz*Kazakh - Russian (Kazakhstan, with Kazakh)
C*layout*kh*Khmer (Cambodia)
C*variant*kh**Khmer (Cambodia)
C*layout*kr*Korean
C*variant*kr**Korean
C*variant*kr*kr104*Korean - Korean (101/104-key compatible)
C*layout*kg*Kyrgyz
C*variant*kg**Kyrgyz
C*variant*kg*phonetic*Kyrgyz - Kyrgyz (phonetic)
C*layout*la*Lao
C*variant*la**Lao
C*variant*la*stea*Lao - Lao (STEA)
C*layout*lv*Latvian
C*variant*lv**Latvian
C*variant*lv*fkey*Latvian - Latvian (F)
C*variant*lv*modern-cyr*Latvian - Latvian (Modern Cyrillic)
C*variant*lv*modern*Latvian - Latvian (Modern Latin)
C*variant*lv*adapted*Latvian - Latvian (adapted)
C*variant*lv*apostrophe*Latvian - Latvian (apostrophe)
C*variant*lv*ergonomic*Latvian - Latvian (ergonomic, ŪGJRMV)
C*variant*lv*tilde*Latvian - Latvian (tilde)
C*layout*lt*Lithuanian
C*variant*lt**Lithuanian
C*variant*lt*ibm*Lithuanian - Lithuanian (IBM)
C*variant*lt*lekp*Lithuanian - Lithuanian (LEKP)
C*variant*lt*lekpa*Lithuanian - Lithuanian (LEKPa)
C*variant*lt*ratise*Lithuanian - Lithuanian (Ratise)
C*variant*lt*us*Lithuanian - Lithuanian (US)
C*variant*lt*std*Lithuanian - Lithuanian (standard)
C*variant*lt*sgs*Lithuanian - Samogitian
C*layout*mk*Macedonian
C*variant*mk**Macedonian
C*variant*mk*nodeadkeys*Macedonian - Macedonian (no dead keys)
C*layout*my*Malay (Jawi, Arabic Keyboard)
C*variant*my**Malay (Jawi, Arabic Keyboard)
C*variant*my*phonetic*Malay (Jawi, Arabic Keyboard) - Malay (Jawi, phonetic)
C*layout*mt*Maltese
C*variant*mt**Maltese
C*variant*mt*alt-gb*Maltese - Maltese (UK, with AltGr overrides)
C*variant*mt*us*Maltese - Maltese (US)
C*variant*mt*alt-us*Maltese - Maltese (US, with AltGr overrides)
C*layout*md*Moldavian
C*variant*md**Moldavian
C*variant*md*gag*Moldavian - Gagauz (Moldova)
C*layout*mn*Mongolian
C*variant*mn**Mongolian
C*layout*me*Montenegrin
C*variant*me**Montenegrin
C*variant*me*cyrillic*Montenegrin - Montenegrin (Cyrillic)
C*variant*me*cyrillicyz*Montenegrin - Montenegrin (Cyrillic, ZE and ZHE swapped)
C*variant*me*cyrillicalternatequotes*Montenegrin - Montenegrin (Cyrillic, with guillemets)
C*variant*me*latinyz*Montenegrin - Montenegrin (Latin, QWERTY)
C*variant*me*latinunicode*Montenegrin - Montenegrin (Latin, Unicode)
C*variant*me*latinunicodeyz*Montenegrin - Montenegrin (Latin, Unicode, QWERTY)
C*variant*me*latinalternatequotes*Montenegrin - Montenegrin (Latin, with guillemets)
C*layout*gn*NKo (AZERTY)
C*variant*gn**NKo (AZERTY)
C*layout*np*Nepali
C*variant*np**Nepali
C*layout*no*Norwegian
C*variant*no**Norwegian
C*variant*no*smi*Norwegian - Northern Saami (Norway)
C*variant*no*smi_nodeadkeys*Norwegian - Northern Saami (Norway, no dead keys)
C*variant*no*colemak*Norwegian - Norwegian (Colemak)
C*variant*no*colemak_dh_wide*Norwegian - Norwegian (Colemak-DH Wide)
C*variant*no*colemak_dh*Norwegian - Norwegian (Colemak-DH)
C*variant*no*dvorak*Norwegian - Norwegian (Dvorak)
C*variant*no*mac*Norwegian - Norwegian (Macintosh)
C*variant*no*mac_nodeadkeys*Norwegian - Norwegian (Macintosh, no dead keys)
C*variant*no*winkeys*Norwegian - Norwegian (Windows)
C*variant*no*nodeadkeys*Norwegian - Norwegian (no dead keys)
C*layout*ir*Persian
C*variant*ir**Persian
C*variant*ir*azb*Persian - Azerbaijani (Iran)
C*variant*ir*ku_ara*Persian - Kurdish (Iran, Arabic-Latin)
C*variant*ir*ku_f*Persian - Kurdish (Iran, F)
C*variant*ir*ku_alt*Persian - Kurdish (Iran, Latin Alt-Q)
C*variant*ir*ku*Persian - Kurdish (Iran, Latin Q)
C*variant*ir*winkeys*Persian - Persian (Windows)
C*variant*ir*pes_keypad*Persian - Persian (with Persian keypad)
C*layout*pl*Polish
C*variant*pl**Polish
C*variant*pl*csb*Polish - Kashubian
C*variant*pl*dvorak*Polish - Polish (Dvorak)
C*variant*pl*dvorak_altquotes*Polish - Polish (Dvorak, with Polish quotes on key 1)
C*variant*pl*dvorak_quotes*Polish - Polish (Dvorak, with Polish quotes on quotemark key)
C*variant*pl*qwertz*Polish - Polish (QWERTZ)
C*variant*pl*legacy*Polish - Polish (legacy)
C*variant*pl*dvp*Polish - Polish (programmer Dvorak)
C*variant*pl*ru_phonetic_dvorak*Polish - Russian (Poland, phonetic Dvorak)
C*variant*pl*szl*Polish - Silesian
C*layout*pt*Portuguese
C*variant*pt**Portuguese
C*variant*pt*nativo-epo*Portuguese - Esperanto (Portugal, Nativo)
C*variant*pt*mac*Portuguese - Portuguese (Macintosh)
C*variant*pt*mac_nodeadkeys*Portuguese - Portuguese (Macintosh, no dead keys)
C*variant*pt*nativo-us*Portuguese - Portuguese (Nativo for US keyboards)
C*variant*pt*nativo*Portuguese - Portuguese (Nativo)
C*variant*pt*nodeadkeys*Portuguese - Portuguese (no dead keys)
C*layout*br*Portuguese (Brazil)
C*variant*br**Portuguese (Brazil)
C*variant*br*nativo-epo*Portuguese (Brazil) - Esperanto (Brazil, Nativo)
C*variant*br*dvorak*Portuguese (Brazil) - Portuguese (Brazil, Dvorak)
C*variant*br*thinkpad*Portuguese (Brazil) - Portuguese (Brazil, IBM/Lenovo ThinkPad)
C*variant*br*nativo-us*Portuguese (Brazil) - Portuguese (Brazil, Nativo for US keyboards)
C*variant*br*nativo*Portuguese (Brazil) - Portuguese (Brazil, Nativo)
C*variant*br*nodeadkeys*Portuguese (Brazil) - Portuguese (Brazil, no dead keys)
C*variant*br*rus*Portuguese (Brazil) - Russian (Brazil, phonetic)
C*layout*ro*Romanian
C*variant*ro**Romanian
C*variant*ro*winkeys*Romanian - Romanian (Windows)
C*variant*ro*std*Romanian - Romanian (standard)
C*layout*ru*Russian
C*variant*ru**Russian
C*variant*ru*ab*Russian - Abkhazian (Russia)
C*variant*ru*bak*Russian - Bashkirian
C*variant*ru*cv*Russian - Chuvash
C*variant*ru*cv_latin*Russian - Chuvash (Latin)
C*variant*ru*xal*Russian - Kalmyk
C*variant*ru*kom*Russian - Komi
C*variant*ru*chm*Russian - Mari
C*variant*ru*os_winkeys*Russian - Ossetian (Windows)
C*variant*ru*os_legacy*Russian - Ossetian (legacy)
C*variant*ru*dos*Russian - Russian (DOS)
C*variant*ru*mac*Russian - Russian (Macintosh)
C*variant*ru*ruchey_en*Russian - Russian (engineering, EN)
C*variant*ru*ruchey_ru*Russian - Russian (engineering, RU)
C*variant*ru*legacy*Russian - Russian (legacy)
C*variant*ru*phonetic*Russian - Russian (phonetic)
C*variant*ru*phonetic_azerty*Russian - Russian (phonetic, AZERTY)
C*variant*ru*phonetic_dvorak*Russian - Russian (phonetic, Dvorak)
C*variant*ru*phonetic_winkeys*Russian - Russian (phonetic, Windows)
C*variant*ru*phonetic_YAZHERTY*Russian - Russian (phonetic, YAZHERTY)
C*variant*ru*typewriter*Russian - Russian (typewriter)
C*variant*ru*typewriter-legacy*Russian - Russian (typewriter, legacy)
C*variant*ru*srp*Russian - Serbian (Russia)
C*variant*ru*tt*Russian - Tatar
C*variant*ru*udm*Russian - Udmurt
C*variant*ru*sah*Russian - Yakut
C*layout*rs*Serbian
C*variant*rs**Serbian
C*variant*rs*rue*Serbian - Pannonian Rusyn
C*variant*rs*yz*Serbian - Serbian (Cyrillic, ZE and ZHE swapped)
C*variant*rs*alternatequotes*Serbian - Serbian (Cyrillic, with guillemets)
C*variant*rs*latin*Serbian - Serbian (Latin)
C*variant*rs*latinyz*Serbian - Serbian (Latin, QWERTY)
C*variant*rs*latinunicode*Serbian - Serbian (Latin, Unicode)
C*variant*rs*latinunicodeyz*Serbian - Serbian (Latin, Unicode, QWERTY)
C*variant*rs*latinalternatequotes*Serbian - Serbian (Latin, with guillemets)
C*layout*lk*Sinhala (phonetic)
C*variant*lk**Sinhala (phonetic)
C*variant*lk*us*Sinhala (phonetic) - Sinhala (US)
C*variant*lk*tam_unicode*Sinhala (phonetic) - Tamil (Sri Lanka, TamilNet 99)
C*variant*lk*tam_TAB*Sinhala (phonetic) - Tamil (Sri Lanka, TamilNet 99, TAB encoding)
C*layout*sk*Slovak
C*variant*sk**Slovak
C*variant*sk*qwerty*Slovak - Slovak (QWERTY)
C*variant*sk*qwerty_bksl*Slovak - Slovak (QWERTY, extra backslash)
C*variant*sk*bksl*Slovak - Slovak (extra backslash)
C*layout*si*Slovenian
C*variant*si**Slovenian
C*variant*si*us*Slovenian - Slovenian (US)
C*variant*si*alternatequotes*Slovenian - Slovenian (with guillemets)
C*layout*es*Spanish
C*variant*es**Spanish
C*variant*es*ast*Spanish - Asturian (Spain, with bottom-dot H and L)
C*variant*es*cat*Spanish - Catalan (Spain, with middle-dot L)
C*variant*es*dvorak*Spanish - Spanish (Dvorak)
C*variant*es*winkeys*Spanish - Spanish (Windows)
C*variant*es*deadtilde*Spanish - Spanish (dead tilde)
C*variant*es*nodeadkeys*Spanish - Spanish (no dead keys)
C*layout*latam*Spanish (Latin American)
C*variant*latam**Spanish (Latin American)
C*variant*latam*colemak*Spanish (Latin American) - Spanish (Latin American, Colemak)
C*variant*latam*dvorak*Spanish (Latin American) - Spanish (Latin American, Dvorak)
C*variant*latam*deadtilde*Spanish (Latin American) - Spanish (Latin American, dead tilde)
C*variant*latam*nodeadkeys*Spanish (Latin American) - Spanish (Latin American, no dead keys)
C*layout*ke*Swahili (Kenya)
C*variant*ke**Swahili (Kenya)
C*variant*ke*kik*Swahili (Kenya) - Kikuyu
C*layout*tz*Swahili (Tanzania)
C*variant*tz**Swahili (Tanzania)
C*layout*se*Swedish
C*variant*se**Swedish
C*variant*se*smi*Swedish - Northern Saami (Sweden)
C*variant*se*rus*Swedish - Russian (Sweden, phonetic)
C*variant*se*dvorak*Swedish - Swedish (Dvorak)
C*variant*se*us_dvorak*Swedish - Swedish (Dvorak, intl.)
C*variant*se*mac*Swedish - Swedish (Macintosh)
C*variant*se*svdvorak*Swedish - Swedish (Svdvorak)
C*variant*se*us*Swedish - Swedish (US)
C*variant*se*nodeadkeys*Swedish - Swedish (no dead keys)
C*variant*se*swl*Swedish - Swedish Sign Language
C*layout*ch*Switzerland
C*variant*ch**Switzerland
C*variant*ch*fr*Switzerland - French (Switzerland)
C*variant*ch*fr_mac*Switzerland - French (Switzerland, Macintosh)
C*variant*ch*fr_nodeadkeys*Switzerland - French (Switzerland, no dead keys)
C*variant*ch*de_mac*Switzerland - German (Switzerland, Macintosh)
C*variant*ch*legacy*Switzerland - German (Switzerland, legacy)
C*variant*ch*de_nodeadkeys*Switzerland - German (Switzerland, no dead keys)
C*layout*tw*Taiwanese
C*variant*tw**Taiwanese
C*variant*tw*saisiyat*Taiwanese - Saisiyat (Taiwan)
C*variant*tw*indigenous*Taiwanese - Taiwanese (indigenous)
C*layout*tj*Tajik
C*variant*tj**Tajik
C*variant*tj*legacy*Tajik - Tajik (legacy)
C*layout*th*Thai
C*variant*th**Thai
C*variant*th*pat*Thai - Thai (Pattachote)
C*variant*th*tis*Thai - Thai (TIS-820.2538)
C*layout*bw*Tswana
C*variant*bw**Tswana
C*layout*tr*Turkish
C*variant*tr**Turkish
C*variant*tr*ku_f*Turkish - Kurdish (Turkey, F)
C*variant*tr*ku_alt*Turkish - Kurdish (Turkey, Latin Alt-Q)
C*variant*tr*ku*Turkish - Kurdish (Turkey, Latin Q)
C*variant*tr*alt*Turkish - Turkish (Alt-Q)
C*variant*tr*e*Turkish - Turkish (E)
C*variant*tr*f*Turkish - Turkish (F)
C*variant*tr*intl*Turkish - Turkish (intl., with dead keys)
C*layout*tm*Turkmen
C*variant*tm**Turkmen
C*variant*tm*alt*Turkmen - Turkmen (Alt-Q)
C*layout*ua*Ukrainian
C*variant*ua**Ukrainian
C*variant*ua*crh_alt*Ukrainian - Crimean Tatar (Turkish Alt-Q)
C*variant*ua*crh_f*Ukrainian - Crimean Tatar (Turkish F)
C*variant*ua*crh*Ukrainian - Crimean Tatar (Turkish Q)
C*variant*ua*winkeys*Ukrainian - Ukrainian (Windows)
C*variant*ua*homophonic*Ukrainian - Ukrainian (homophonic)
C*variant*ua*legacy*Ukrainian - Ukrainian (legacy)
C*variant*ua*macOS*Ukrainian - Ukrainian (macOS)
C*variant*ua*phonetic*Ukrainian - Ukrainian (phonetic)
C*variant*ua*typewriter*Ukrainian - Ukrainian (typewriter)
C*layout*pk*Urdu (Pakistan)
C*variant*pk**Urdu (Pakistan)
C*variant*pk*ara*Urdu (Pakistan) - Arabic (Pakistan)
C*variant*pk*snd*Urdu (Pakistan) - Sindhi
C*variant*pk*urd-crulp*Urdu (Pakistan) - Urdu (Pakistan, CRULP)
C*variant*pk*urd-nla*Urdu (Pakistan) - Urdu (Pakistan, NLA)
C*layout*uz*Uzbek
C*variant*uz**Uzbek
C*variant*uz*latin*Uzbek - Uzbek (Latin)
C*layout*vn*Vietnamese
C*variant*vn**Vietnamese
C*variant*vn*fr*Vietnamese - Vietnamese (France)
C*variant*vn*us*Vietnamese - Vietnamese (US)
C*layout*sn*Wolof
C*variant*sn**Wolof
EOF
}

# all_kbdnames () {
#  cat <<'EOF' 
# C*model*logidinovo*Logitech diNovo Keyboard
# C*model*amiga*Amiga
# ...
# zh_TW*layout*al*阿爾巴尼亞
# zh_TW*variant*al**阿爾巴尼亞
# EOF
# }



keyboard_present () {
    local kern kbdpattern class subclass protocol

    kern=`uname -r`
    case "$kern" in
	2.0*|2.1*|2.2*|2.3*|2.4*|2.5*)
	    # can't check keyboard presence
	    return 0; 
	    ;;
    esac

    [ -d /sys/bus/usb/devices ] || return 0
    for d in /sys/bus/usb/devices/*:*; do
	[ -d "$d" ] || continue
	class=$(cat "$d/bInterfaceClass") # 03 = Human Interface Device
	subclass=$(cat "$d/bInterfaceSubClass") # 01 = Boot Interface Subclass
	protocol=$(cat "$d/bInterfaceProtocol") # 01 = Keyboard
	case "$class:$subclass:$protocol" in
	    03:01:01)
		return 0
		;;
	esac
    done

    # For Bluetooth keyboards one has to check the class of the device
    # -- it has to be 0x000540 or 0x002540.  I don't how to make the
    # required test, so instead we test (unreliably) for a string
    # bluetooth.*keyboard in /proc/bus/input/devices.

    [ -f /proc/bus/input/devices ] || return 0
    kbdpattern="AT Set \|AT Translated Set\|AT Raw Set"
    kbdpattern="$kbdpattern\|Atari Keyboard"
    kbdpattern="$kbdpattern\|Amiga Keyboard"
    kbdpattern="$kbdpattern\|HIL keyboard"
    kbdpattern="$kbdpattern\|ADB keyboard"
    kbdpattern="$kbdpattern\|Sun Type"
    kbdpattern="$kbdpattern\|bluetooth.*keyboard"
    if grep -i "$kbdpattern" /proc/bus/input/devices >/dev/null; then
	return 0
    fi

    return 1
}

# keyboard_present () {
#     if there is a keyboard; then
# 	return 0
#     else
# 	return 1
#     fi
# }

######################################################################
#    Function ask_debconf.  Ask the user to choose amongst the options
#    listed in $kbdnames.
######################################################################

ask_debconf () {
    local template priority prefix default_code default_description choices add

    # The template to ask
    template="$1"
    # The priority for the question
    priority="$2"
    # The prefix for $kbdnames
    prefix="$(echo "$3"|regex_pattern_escape)"
    # The default choice (optional)
    default_code="$(echo "$4"|regex_pattern_escape)"
    # Additional string to append to $kbdnames
    add="$(echo "$5"|regex_escape)"
    add="
$add"

    choices1=`echo "$kbdnames" | grep "^$prefix\*" | 
        sed -e "s/^$prefix\*[^\*]*\*//" -e 's/,/\\\\,/g' | sort`
    choices2=`echo "$add" | grep "^$prefix\*" | 
        sed -e "s/^$prefix\*[^\*]*\*//" -e 's/,/\\\\,/g'`
    choices=`echo "$choices1
$choices2" | sed -e 's/$/,/'`
    choices=`echo $choices | sed 's/, *$//' | regex_unescape`

    choices=`echo $choices | sed 's/,$//'`

    if echo "$choices" | grep '[^\\\\],' >/dev/null; then
	db_subst $template CHOICES "$choices"
	default_description=`echo "$kbdnames$add" |  
            grep "^$prefix\*${default_code}\*" |
            sed -e "s/^$prefix\*${default_code}\*//" |
	    regex_unescape`
	if [ -z "$default_description" ]; then
	    # For XkbVariant the empty string is usually a sensible default
	    default_description=`echo "$kbdnames$add" |  
                grep "^$prefix\*\*" |
		sed -e "s/^$prefix\*\*//" |
		regex_unescape `
	fi
	if [ -n "$default_description" ]; then
	    db_default $template "$default_description"
	elif [ -n "$default_code" ]; then
	    # A default was requested, but we couldn't resolve it to a
	    # description, so we'd better ask.
	    priority=critical
	fi
	
        db_input $priority $template || true
	db_go || return 255
	db_get $template
    else
	# There is only one choice - no need to use debconf
	[ $STATE -gt $old_state ] || return 255
	RET=$(echo "$choices"|sed 's/ *$//')
    fi

    RET=`echo "$RET" | regex_pattern_escape`
    RET=`echo "$kbdnames$add" | grep "^$prefix\*[^\*]*\*" |
             sed 's/  */ /g' |
             grep "\*$RET\$" |
             sed -e "s/^$prefix\*\([^\*]*\)\*.*/\1/" |
	     regex_unescape`
    return 0
}

######################################################################
#    Function guess_arch - detect the architecture and subarchitecture
######################################################################

# The guess arch code is taken from "console-data.conf"
# (translated from Perl to shell)

# SUBARCH	KEYMAP SET	DETECTION
# m68k/atari	atari		"Model: Atari"
# m68k/amiga	amiga		"Model: Amiga"
# m68k/mac	mac		"Model: Macintosh"
# m68k/mvme	pc		"Model: Motorola"
# m68k/bvme	pc		"Model: BVME[46]000"
# m68k/{sun,apollo,next,q40,hp300} Not supported by Debian

# ppc/apus	amiga		"machine: Amiga"
# ppc/chrp	pc,mac		"machine: CHRP"
# ppc/pmac	mac		"machine: PowerMac|[Pp]ower[Bb]ook*|Power|iMac*|PowerMac1*"
# ppc/prep	pc		"machine: PReP"
# ppc/ps3	pc		"platform: PS3"
# ppc/cell	pc		"platform: Cell"
# ppc/{bbox,mbx,ppc64,82xx,8xx} Not yet supported by Debian

# arm/*		pc		(refered to as 'arm' only)

guess_arch () {
    local arch subarch line

    if which archdetect 2>/dev/null >/dev/null; then
	archdetect
	return 0
    fi

    arch=`dpkg --print-architecture`
    
    if [ "$arch" = 'powerpc' -o "$arch" = 'm68k' ]; then
	if [ "$arch" = powerpc ]; then
	    line=`sed -n 's/^platform.*: *//p' /proc/cpuinfo`
	    if [ "$line" = PS3 ] || [ "$line" = Cell ]; then
		subarch=`echo $line|tr A-Z a-z`
	    else
		line=`sed -n 's/^machine.*: *//p' /proc/cpuinfo`
		if [ "$line" = '' ]; then
		    echo unknown
		    return 0
		fi
		subarch=`echo $line|tr A-Z a-z`
	    fi
	elif [ "$arch" = m68k ]; then
	    line=`sed -n 's/^Model.*: *//p' /proc/hardware`
	    if [ "$line" = '' ]; then
		echo unknown
		return 0
	    fi
	    subarch=`echo $line|tr A-Z a-z`
	fi
	case "$subarch" in
	    *amiga*)
		subarch=amiga
		;;
	    *chrp*)
		subarch=chrp
		;;
	    *prep*)
		subarch=prep
		;;
	    *macintosh*|*powermac*|*powerbook*|*power*|*imac*|*powermac1*)
		subarch=mac
		;;
	    *atari*)
		subarch=atari
		;;
	    *motorola*)
		subarch=mvme
		;;
	    *bvme*)
		subarch=bvme
		;;
	    *)
		subarch=`echo $subarch|sed  's/^\s*//'`
		;;
	esac
	arch="$arch/$subarch"
    fi
    echo $arch
    return 0
}

#########################################################################
# Set $locale.  Extract the strings for the chosen language in $kbdnames
#########################################################################

if which locale 2>/dev/null >/dev/null; then
    eval `locale`
fi

if [ "$LC_CTYPE"  -a "$LC_CTYPE" != C ]; then
    locale=$LC_CTYPE
elif db_get debian-installer/locale && [ "$RET" ]; then
    locale="$RET"
else
    locale=C
fi

langcountry="$locale"
if ! type locale >/dev/null 2>&1 || [ "$OVERRIDE_USE_DEBCONF_LOCALE" ]; then
    if db_get localechooser/languagelist && [ "$RET" ]; then
	lang="$RET"
	if db_get debian-installer/country && [ "$RET" ]; then
	    langcountry="${lang}_$RET"
	fi
    fi
fi

if [ "$LC_MESSAGES"  -a "$LC_MESSAGES" != C ]; then
    messages=$LC_MESSAGES
elif db_get debian-installer/locale && [ "$RET" ]; then
    messages="$RET"
else
    messages=C
fi

messages_lang=$(echo $messages | sed 's/_.*//')
messages_country=$(echo $messages | sed 's/.*_//;s/\..*//;s/@.*//')
messages_modif=
echo $messages | grep -v -q @ || messages_modif=$(echo $messages | sed 's/.*@//')

lang_kbdnames () {
    all_kbdnames | \
	regex_escape | \
	grep "^$1[*]" | \
	sed "s/^$1[*]//"
}

kbdnames=$(lang_kbdnames ${messages_lang}_${messages_country}__${messages_modif})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames ${messages_lang}_${messages_country}__${messages_modif})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames ${messages_lang}_${messages_country})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames ${messages_lang})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames C)

if [ "$is_not_debian_installer" ]; then
    if \
        ! which iconv >/dev/null \
        || ! kbdnames="$(echo "$kbdnames" |
                iconv -f UTF-8 -t $(locale charmap)//TRANSLIT)"
    then
        kbdnames=$(lang_kbdnames C)
    fi
fi

######################################################################
#    Compute default values for $XKBMODEL, $XKBLAYOUT, $XKBVARIANT
#    based on the architecture and the locale.
######################################################################

arch=`guess_arch`
case "$arch" in
    alpha*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    amd64*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    arm*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    i386*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    hppa*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    ia64*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    m68k/amiga)
	XKBMODEL=amiga
	model_priority=medium
	;;
    m68k/atari)
	XKBMODEL=ataritt
	model_priority=medium
	;;
    m68k/mac)
	XKBMODEL=macintosh
	model_priority=medium
	;;
    m68k/sun*)
	XKBMODEL=pc105 # UNKNOWN: sun4, sun5 or pc105
	model_priority=critical
	;;
    m68k/*vme*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    mips*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    powerpc/amiga)
	XKBMODEL=amiga
	model_priority=medium
	;;
    powerpc/apus)
	XKBMODEL=amiga
	model_priority=medium
	;;
    powerpc/chrp*)
	XKBMODEL=pc105 # UNKNOWN: pc105, macintosh or maybe amiga
	model_priority=critical
	;;
    powerpc/mac)
	XKBMODEL=pc105
	model_priority=medium
	;;
    powerpc/pasemi)
	XKBMODEL=pc105
	model_priority=medium
	;;
    powerpc/powermac*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    powerpc/prep)
	XKBMODEL=pc105
	model_priority=medium
	;;
    powerpc/ps3|powerpc/cell)
	XKBMODEL=pc105
	model_priority=medium
	;;
    ppc64el/*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    sparc*)
	XKBMODEL=pc105 # sun4 or sun5 on older kernels
	model_priority=medium
	;;
    s390*)
	XKBMODEL=pc105
	model_priority=medium
	;;
    *)
	XKBMODEL=pc105 # UNKNOWN
	model_priority=critical
	;;
esac    

layout_priority=high
case "$langcountry" in
    # Keyboards for countries
    *_AL*)
	XKBLAYOUT=al  # Albania
	;;
    *_AZ*)
	XKBLAYOUT=az  # Azerbaijan
	;;
    *_BD*)
	XKBLAYOUT=us,bd  # Bangladesh
	;;
    *_BE*)
	XKBLAYOUT=be  # Belgium
	;;
    *_BG*)
	XKBLAYOUT=us,bg  # Bulgaria
	layout_priority=critical
	;;
    *_BR*)
	XKBLAYOUT=br  # Brazil
	;;
    *_BT*)
	XKBLAYOUT=us,bt  # Bhutan
	;;
    *_BY*)
	XKBLAYOUT=us,by  # Belarus
	;;
    fr_CA*)
	XKBLAYOUT=ca  # Canada
	;;
    *_CA*)
	XKBLAYOUT=us  # U.S. English
	;;
    de_CH*)
	XKBLAYOUT=ch  # Switzerland
	;;
    fr_CH*)
	XKBLAYOUT=ch  # Switzerland
	XKBVARIANT=fr # French
	;;
    *_CH*)
	XKBLAYOUT=ch  # Switzerland
	layout_priority=critical
	;;
    *_CZ*)
	XKBLAYOUT=cz  # Czechia
	layout_priority=critical
	;;
    *_DK*)
	XKBLAYOUT=dk  # Denmark
	;;
    *_EE*)
	XKBLAYOUT=ee  # Estonia
	;;
    ast_ES*)
	XKBLAYOUT=es  # Spain
	XKBVARIANT=ast # Asturian
	;;
    bo_*)
	XKBLAYOUT=us,cn  # China
	XKBVARIANT=,tib # Tibetan
	;;
    ca_ES*)
	XKBLAYOUT=es  # Spain
	XKBVARIANT=cat # Catalan
	;;
    *_ES*)
	XKBLAYOUT=es  # Spain
	;;
    *_ET*)
	XKBLAYOUT=us,et  # Ethiopia
	;;
    se_FI*)
	XKBLAYOUT=fi  # Finland
	XKBVARIANT=smi # Northern Saami
	;;
    *_FI*)
	XKBLAYOUT=fi  # Finland
	;;
    *_FR*)
	XKBLAYOUT=fr  # French
	XKBVARIANT=latin9
	;;
    *_GB*)
	XKBLAYOUT=gb  # United Kingdom
	;;
    *_GG*)
	XKBLAYOUT=gb  # United Kingdom
	;;
    *_HU*)
	XKBLAYOUT=hu  # Hungary
	;;
    *_IE*)
	XKBLAYOUT=ie  # Ireland
	;;
    *_IL*)
	XKBLAYOUT=us,il  # Israel
	layout_priority=critical
	;;
    *_IM*)
	XKBLAYOUT=gb  # United Kingdom
	;;
    *_IR*)
	XKBLAYOUT=us,ir  # Iran
	;;
    *_IS*)
	XKBLAYOUT=is  # Iceland
	;;
    *_IT*)
	XKBLAYOUT=it  # Italy
	;;
    *_JE*)
	XKBLAYOUT=gb  # United Kingdom
	;;
    *_JP*)
	XKBLAYOUT=jp  # Japan
	;;
    *_LT*)
	XKBLAYOUT=lt  # Lithuania
	layout_priority=critical
	;;
    *_LV*)
	XKBLAYOUT=lv  # Latvia
	;;
    *_KG*)
	XKBLAYOUT=us,kg  # Kyrgyzstan
	;;
    *_KH*)
	XKBLAYOUT=us,kh  # Cambodia
	;;
    *_KR*)
	XKBLAYOUT=kr      # South Korea
	XKBVARIANT=kr104  # pc104 compatible mode, safe choice
	;;
    *_KZ*)
	XKBLAYOUT=us,kz  # Kazakhstan
	;;
    *_LK*)
	XKBLAYOUT=us,lk  # Sri Lanka
	;;
    *_MA*)
	XKBLAYOUT=us,ma  # Morocco
	;;
    *_MK*)
	XKBLAYOUT=us,mk  # Macedonia
	;;
# According to https://launchpad.net/bugs/129982, Dutch users prefer the US
# intl keymap.
    *_NL*)
	XKBLAYOUT=us  # Netherlands
	XKBVARIANT=intl # International (with dead keys)
	;;
    *_MM*)
	XKBLAYOUT=us,mm  # Myanmar
	;;
    *_MN*)
	XKBLAYOUT=us,mn  # Mongolia
	;;
    *_MT*)
	XKBLAYOUT=mt  # Malta
	layout_priority=critical
	;;
    se_NO*)
	XKBLAYOUT=no  # Norway
	XKBVARIANT=smi # Northern Saami
	;;
    *_NO*)
	XKBLAYOUT=no  # Norway (se_NO is not in this case)
	;;
    *_NP*)
	XKBLAYOUT=us,np  # Nepal
	;;
    *_PH*)
	XKBLAYOUT=ph  # Philipines
	;;
    *_PL*)
	XKBLAYOUT=pl  # Poland
	;;
    *_PT*)
	XKBLAYOUT=pt  # Portugal
	;;
    *_RO*)
	XKBLAYOUT=ro  # Romania
	;;
    *_RU*)
	XKBLAYOUT=us,ru  # Russia
	layout_priority=critical
	;;
    se_SE*)
	XKBLAYOUT=se  # Sweden
	XKBVARIANT=smi # Northern Saami
	;;
    *_SK*)
	XKBLAYOUT=sk  # Slovakia
	;;
    *_SI*)
	XKBLAYOUT=si  # Slovenia
	;;
    tg_*)
	XKBLAYOUT=us,tj  # Tajik
	;;
    *_TJ*)
	XKBLAYOUT=us,tj  # Tajikistan
	;;
    *_TH*)
	XKBLAYOUT=us,th  # Thailand
	layout_priority=critical
	;;
    ku_TR*)
	XKBLAYOUT=tr  # Turkish
	XKBVARIANT=ku # Kurdish, Latin Q
	;;
    *_TR*)
	XKBLAYOUT=tr  # Turkish
	layout_priority=critical
	;;
    zh_TW*)
	XKBLAYOUT=tw  # Taiwanese
	XKBVARIANT=indigenous
	;;
    *_UA*)
	XKBLAYOUT=us,ua  # Ukraine
	;;
    en_US*)
	XKBLAYOUT=us  # U.S. English
	;;
# According to https://launchpad.net/bugs/191451, most keyboards in Vietnam
# are in fact US keyboards.
    *_VN*)
	XKBLAYOUT=us  # Vietnam
	;;
    *_ZA*)
	XKBLAYOUT=za  # South Africa
	;;
    # Keyboards for specific languages and international keyboards:
    # TODO: Is the following list correct?
    *_AR*|*_BO*|*_CL*|*_CO*|*_CR*|*_DO*|*_EC*|*_GT*|*_HN*|*_MX*|*_NI*|*_PA*|*_PE*|es_PR*|*_PY*|*_SV*|es_US*|*_UY*|*_VE*)
	XKBLAYOUT=latam # Latin American
	;;
    ar_*)
	XKBLAYOUT=us,ara # Arabic
	;;
    bn_*)
	XKBLAYOUT=us,in  # India
	XKBVARIANT=,ben # Bengali
	;;
    bs_*)
	XKBLAYOUT=ba  # Bosnia and Herzegovina
	;;
    de_LI*)
	XKBLAYOUT=ch  # Liechtenstein
	;;
    de_*)
	XKBLAYOUT=de  # Germany
	;;
    el_*)
	XKBLAYOUT=us,gr  # Greece
	;;
    eo|eo.*|eo_*|eo\@*)
	XKBLAYOUT=epo  # Esperanto
	layout_priority=critical
	;;
    fr_*)
	XKBLAYOUT=fr  # France
	XKBVARIANT=oss # Alternative
	layout_priority=critical
	;;
    gu_*)
	XKBLAYOUT=us,in  # India
	XKBVARIANT=,guj # Gujarati
	;;
    hi_*)
	XKBLAYOUT=us,in  # India
	;;
    hr_*)
	XKBLAYOUT=hr  # Croatia
	;;
    hy_*)
	XKBLAYOUT=us,am  # Armenia
	;;
    ka_*)
	XKBLAYOUT=us,ge  # Georgia
	layout_priority=critical
	;;
    kab_*)
	XKBLAYOUT=dz  # Algeria
	XKBVARIANT=la # Berber (Latin)
	;;
    kn_*)
	XKBLAYOUT=us,in  # India
	XKBVARIANT=,kan # Kannada
	;;
    ku_*)
	XKBLAYOUT=tr  # Turkish
	XKBVARIANT=ku # Kurdish
	layout_priority=critical
	;;
    lo_*)
	XKBLAYOUT=us,la  # Laos
	;;
    mr_*)
	XKBLAYOUT=us,in  # India
	;;
    ml_*)
	XKBLAYOUT=us,in  # India
	XKBVARIANT=,mal # Malayalam
	;;
    my_*)
	XKBLAYOUT=us,mm  # Burmese
	;;
    ne_*)
	XKBLAYOUT=us,np  # Nepali
	;;
    os_*)
	XKBLAYOUT=ru  # Russia
	XKBVARIANT=os  # Ossetian
	;;
    pa_*)
	XKBLAYOUT=us,in  # India
	XKBVARIANT=,guru # Gurmukhi
	;;
    si_*)
	XKBLAYOUT=us,si  # Sri Lanka
	XKBVARIANT=,sin_phonetic # Sinhala
	;;
    sr_*)
	XKBLAYOUT=rs,rs  # Serbia and Montenegro
	XKBVARIANT=latin,
	layout_priority=critical
	;;
    sv_*)
	XKBLAYOUT=se  # Sweden
	;;
    ta_*)
	XKBLAYOUT=us,in  # India
	XKBVARIANT=,tam # Tamil
	;;
    te_*)
	XKBLAYOUT=us,in  # India
	XKBVARIANT=,tel # Telugu
	;;
    tg_*)
	XKBLAYOUT=us,tj  # Tajikistan
	;;
    the_*)
	XKBLAYOUT=us,np  # Nepali keymap for Tharu
	;;
    tl_*)
	XKBLAYOUT=ph  # Philipines
	;;
    ug_*)
	XKBLAYOUT=us,cn  # China
	XKBVARIANT=,ug # Uyghur
	;;
    zh_*)
	XKBLAYOUT=cn  # Chinese
	;;
    # Fallback
    *)
	XKBLAYOUT=us
	;;
esac

######################################################################
#    Overwrite (some of) the computed default values by:
#    - preseeded values (for the udeb);
#    - the value of debian-installer/keymap
#    - the contents of /etc/X11/xorg.conf
#    - the settings in the configuration files (/etc/default/...).
#    - correct some bugs of previous versions of console-setup
######################################################################

# Get defaults from debconf, to allow preseeding in the udeb
if db_get keyboard-configuration/modelcode && [ "$RET" ]; then
    XKBMODEL="$RET"
fi
if db_get keyboard-configuration/layoutcode && [ "$RET" ]; then
    # Don't use the default variant if the layout is being overridden.
    if [ "$RET" != "$XKBLAYOUT" ]; then
	XKBVARIANT=''
    fi
    XKBLAYOUT="$RET"
    if db_fget keyboard-configuration/layoutcode seen && [ "$RET" = true ]; then
	layout_priority=medium
	db_set console-setup/ask_detect false
	db_fset console-setup/ask_detect seen true
    fi
fi
if db_get keyboard-configuration/variantcode && [ "$RET" ]; then
    XKBVARIANT="$RET"
fi
if db_get keyboard-configuration/optionscode && [ "$RET" ]; then
    XKBOPTIONS="$RET"
fi

# Use the value of console-data debian-installer/keymap to get better default
# layout.  This guesswork is copied from xserver-xorg.config.
# Lower the priority of the Debconf question to medium.
if db_get debian-installer/keymap && [ "$RET" ]; then
    di_keymap="${RET##mac-usb-}"
    di_keymap="${di_keymap%%-latin1}"
    
    old_xkbvariant="$XKBVARIANT"
    XKBVARIANT=''
    old_layout_priority=$layout_priority
    layout_priority=medium
    case "$di_keymap" in
	be2) XKBLAYOUT="be";;
	bg) XKBLAYOUT="us,bg";;
	br) XKBLAYOUT="us"; XKBVARIANT="intl";;
	br-abnt2) XKBLAYOUT="br"; XKBVARIANT="abnt2";;
	by) XKBLAYOUT="us,by";;
	cf) XKBLAYOUT="ca"; XKBVARIANT="fr";;
	croat) XKBLAYOUT="hr";;
	cz-lat2) XKBLAYOUT="cz";;
	de-latin1-nodeadkeys) XKBLAYOUT="de"; XKBVARIANT="nodeadkeys";;
	de) XKBLAYOUT="de";;
	dvorak) XKBLAYOUT="us"; XKBVARIANT="dvorak";;
	dk) XKBLAYOUT="dk";;
	es) XKBLAYOUT="es";;
	et) XKBLAYOUT="ee";;
	'fi') XKBLAYOUT="fi";;
	fr-latin9) XKBLAYOUT="fr"; XKBVARIANT="latin9";;
	fr_CH) XKBLAYOUT="ch"; XKBVARIANT="fr";;
	fr) XKBLAYOUT="fr";;
	hebrew) XKBLAYOUT="us,il";;
	hu) XKBLAYOUT="hu";;
	gb) XKBLAYOUT="gb";;
	is) XKBLAYOUT="is";;
	it) XKBLAYOUT="it";;
	jp106) XKBLAYOUT="jp"; XKBVARIANT="106";;
	kr|kr106) XKBLAYOUT="kr"; XKBVARIANT='';;
	kr104) XKBLAYOUT="kr"; XKBVARIANT="kr104";;
	la) XKBLAYOUT="latam";;
	lt) XKBLAYOUT="lt";; 
	lv-latin4) XKBLAYOUT="lv";;
	mac-us-std) XKBLAYOUT="us";;
	mac-de2-ext) XKBLAYOUT="de"; XKBVARIANT="nodeadkeys";;
	mac-fr2-ext) XKBLAYOUT="fr";;
	mac-fr3) XKBLAYOUT="fr";;
	mac-es) XKBLAYOUT="es";;
	ky) XKBLAYOUT="us,kg";;
	mk) XKBLAYOUT="us,mk";;
	nl) XKBLAYOUT="nl";;
	no) XKBLAYOUT="no";;
	pl) XKBLAYOUT="pl";;
	pt) XKBLAYOUT="pt";;
	ro) XKBLAYOUT="ro";;
	ru) XKBLAYOUT="us,ru";;
	se) XKBLAYOUT="se";;
	sg) XKBLAYOUT="ch"; XKBVARIANT="de";;
	sk-qwerty) XKBLAYOUT="sk"; XKBVARIANT="qwerty";;
	slovene) XKBLAYOUT="si";;
	sr-cy) XKBLAYOUT="rs,rs"; XKBVARIANT="latin," ;;
	trf|trfu) XKBLAYOUT="tr"; XKBVARIANT="f";;
	trq|trqu) XKBLAYOUT="tr";;
	ua) XKBLAYOUT="us,ua";;
	uk) XKBLAYOUT="gb";;
	us) XKBLAYOUT="us";;
	*) 
	    XKBVARIANT="$old_xkbvariant"
	    layout_priority=$old_layout_priority
	    ;;
    esac
fi

# Get default layout from xorg.conf if available
# Lower the priority of the Debconf question to medium.
if \
    [ -f /etc/X11/xorg.conf -a ! -e $CONFIGFILE ] \
    && which awk 2>/dev/null >/dev/null
then
    awk_expr='
{
    sub("#.*","")
    line = $0;
    $0 = tolower($0);
    xkb = "";
}

/^[ \t]*section[ \t]+"inputdevice"/,/^[ \t]*endsection/ {
    if ($1 == "option") {
	if ($2 == "\"xkbmodel\"") {
	    xkb = "XKBMODEL";
	} else if ($2 == "\"xkblayout\"") {
	    xkb = "XKBLAYOUT";
	    print "layout_priority=medium";
	} else if ($2 == "\"xkbvariant\"") {
	    xkb = "XKBVARIANT";
	} else if ($2 == "\"xkboptions\"") {
	    xkb = "XKBOPTIONS"; 
	}
	$0 = line;
	$1 = "";
	$2 = "";
    }
}

xkb != "" && /^[ \t]*\"[^"]+\"[ \t]*$/ {
    sub("^[ \t]*\"", "");
    sub("\".*", "");
    gsub("[ \t]", "");
    if ($1 !~ /[()]/) {
	print xkb "=\"" $0 "\"";
    } else {
	if (xkb == "XKBLAYOUT" && $1 ~ /^[^()]+\([^()]+\)$/) {
	    l=$1;                      # us(intl),cz(qwerty)
	    gsub(/\([^()]*\)/,"",l);   # us,cz
	    v=$1;                      # us(intl),cz(qwerty)     us,bg
	    gsub(/\)/,"",v);           # us(intl,cz(qwerty       us,bg
	    gsub(/^[^(,]*,/,",",v);    # us(intl,cz(qwerty       ,bg
	    gsub(/^[^(,]*$/,"",v);     # us(intl,cz(qwerty       ,bg
	    gsub(/^[^(,]*\(/,"",v);    # intl,cz(qwerty          ,bg
	    gsub(/,[^(,]*,/,",,",v);   # intl,cz(qwerty          ,bg
	    gsub(/,[^(,]*$/,",",v);    # intl,cz(qwerty          ,
	    gsub(/,[^(,]*\(/,",",v);   # intl,qwerty             ,
	    print "XKBLAYOUT=" l;
	    print "XKBVARIANT=" v;
	}
    }
}
'
    eval $(awk "$awk_expr" < /etc/X11/xorg.conf)
fi

# Load the config file, if it exists.  Overwrite the current values of
# XKBMODEL, XKBLAYOUT, XKBVARIANT, and XKBOPTIONS in the process.
read_config $OLDCONFIGFILE
read_config $CONFIGFILE

XKBMODEL=$(echo $XKBMODEL | sed 's/ *//g')
XKBLAYOUT=$(echo $XKBLAYOUT | sed 's/ *//g')
XKBVARIANT=$(echo $XKBVARIANT | sed 's/ *//g')

# Version 1.37 of console-setup would destroy the values of $XKBMODEL,
# $XKBLAYOUT and $XKBVARIANT in the configfile if sharutils was not
# installed.  Version 1.47 destroyed $XKBMODEL.
if [ -z "$XKBMODEL" ]; then
    model_priority=critical
    XKBMODEL=pc105
    db_fset keyboard-configuration/model seen false
fi
if [ -z "$XKBLAYOUT" ]; then
    layout_priority=critical
    XKBLAYOUT=us
    db_fset keyboard-configuration/layout seen false
    db_fset keyboard-configuration/variant seen false
fi

#######################################################################
#    If the computer doesn't have keyboard then do not ask questions,
#    simply store the default values in the configuration file.  This
#    is in order to support headless installs in d-i.  The regular
#    packages (console-setup and console-setup-mini) should not be
#    installed on such sistems.
#######################################################################

if ! keyboard_present; then
    # No questions, just store the defaults for postinst
    db_set keyboard-configuration/modelcode "$XKBMODEL"
    db_set keyboard-configuration/layoutcode "$XKBLAYOUT"
    db_set keyboard-configuration/variantcode "$XKBVARIANT"
    if [ -z "$XKBOPTIONS" -a ! -f $CONFIGFILE ]; then
	case "$XKBLAYOUT" in
	    *,*) XKBOPTIONS="grp_led:scroll";;
	    us) XKBOPTIONS="";;
	    *) XKBOPTIONS="lv3:ralt_switch";;
	esac
    fi
    db_set keyboard-configuration/optionscode "$XKBOPTIONS"
    exit 0
fi

#######################################################################
#    Compute default values for the Debconf questions.  For example
#    from XKBLAYOUT=us,el we obtain debconf_layout=el and from
#    XKBOPTIONS=lv3:ralt_switch we obtain debconf_altgr='Right Alt (AltGr)'
#######################################################################

# Set debconf_model.  There is no difference between debconf_model and
# XKBMODEL, but lets create a new variable for consistency.
debconf_model="$XKBMODEL"

# Compute debconf_layout, debconf_variant and unsupported_layout based
# on values of $XKBLAYOUT and $XKBVARIANT.
if [ "$XKBLAYOUT" ]; then
    case "$XKBLAYOUT" in
	lt,us)
	    debconf_layout="${XKBLAYOUT%,*}"
	    debconf_variant="${XKBVARIANT%,*}"
	    unsupported_layout=no
	    ;;
	rs,rs|us,rs|jp,jp|us,jp)
	    debconf_layout="${XKBLAYOUT#*,}"
	    debconf_variant="${XKBVARIANT#*,}"
	    unsupported_layout=no
	    ;;
	# TODO: make s.t. to not forget to update this list
	us,am|us,af|us,ara|us,ben|us,bd|us,bg|us,bt|us,by|us,cn|us,et|us,ge|us,gh|us,gr|us,guj|us,guru|us,il|us,in|us,ir|us,iku|us,iq|us,ir|us,kan|us,kh|us,kz|us,la|us,lao|us,lk|us,lt|us,kg|us,ma|us,mal|us,mk|us,mm|us,mn|us,mv|us,np|us,ori|us,pk|us,ru|us,scc|us,sy|us,syr|us,tel|us,th|us,tj|us,tam|us,tib|us,ua|us,ug|us,uz)
	    if [ "${XKBVARIANT%,*}" = '' ]; then
		debconf_layout="${XKBLAYOUT#*,}"
		debconf_variant="${XKBVARIANT#*,}"
		unsupported_layout=no
	    else
		unsupported_layout=yes
	    fi
	    ;;	    
	*,*)
	    unsupported_layout=yes
	    ;;
	*)
	    debconf_layout="$XKBLAYOUT"
	    debconf_variant="$XKBVARIANT"
            unsupported_layout=no
	    ;;
    esac
fi

# Make sure debconf_layout and debconf_variant point to existing in
# $kbdnames layout and variant.  If the requested layout and/or
# variant are not in the $kbdnames, then we prefer debconf_layout=us
# and debconf_variant=''
if \
    ! echo "$kbdnames" \
    | grep "variant[*]$debconf_layout[*]$debconf_variant[*]" >/dev/null
then
    unsupported_layout=yes
    debconf_variant=''
    if \
	! echo "$kbdnames" \
	| grep "layout[*]$debconf_layout[*]" >/dev/null
    then
	debconf_layout=us
    fi
fi

# Compute debconf_* variables based on the value of $XKBOPTIONS.  The
# values of these variables are human-friendly text.
debconf_toggle='No toggling'
debconf_switch='No temporary switch'
debconf_altgr='The default for the keyboard layout'
debconf_compose='No compose key'
debconf_ctrl_alt_bksp=false
if [ "$XKBOPTIONS" ]; then
    debconf_toggle='No toggling'
    debconf_switch='No temporary switch'
    debconf_altgr='The default for the keyboard layout'
    debconf_compose='No compose key'
    for option in `echo $XKBOPTIONS | sed 's/,/ /g'`; do
	case "$option" in
	    compose:caps)
		debconf_compose='Caps Lock';;
	    compose:lwin)
		debconf_compose='Left Logo key';;
	    compose:menu)
		debconf_compose='Menu key';;
	    compose:ralt)
		debconf_compose='Right Alt (AltGr)';;
	    compose:rctrl)
		debconf_compose='Right Control';;
	    compose:rwin)
		debconf_compose='Right Logo key';;
	    grp:alt_caps_toggle)
		debconf_toggle='Alt+Caps Lock';;
	    grp:alt_shift_toggle)
		debconf_toggle='Alt+Shift';;
	    grp:caps_toggle)
		debconf_toggle='Caps Lock';;
	    grp:ctrl_alt_toggle)
		debconf_toggle='Control+Alt';;
	    grp:ctrl_shift_toggle)
		debconf_toggle='Control+Shift';;
	    grp:lalt_toggle)
		debconf_toggle='Left Alt';;
	    grp:lctrl_lshift_toggle)
		debconf_toggle='Left Control+Left Shift';;
	    grp:lctrl_toggle)
		debconf_toggle='Left Control';;
	    grp:lshift_toggle)
		debconf_toggle='Left Shift';;
	    grp:lswitch)
		debconf_switch='Left Alt';;
	    grp:lwin_switch)
		debconf_switch='Left Logo key';;
	    grp:lwin_toggle)
		debconf_toggle='Left Logo key';;
	    grp:menu_toggle)
		debconf_toggle='Menu key';;
	    grp:rctrl_toggle)
		debconf_toggle='Right Control';;
	    grp:rshift_toggle)
		debconf_toggle='Right Shift';;
	    grp:rwin_switch)
		debconf_switch='Right Logo key';;
	    grp:rwin_toggle)
		debconf_toggle='Right Logo key';;
	    grp:sclk_toggle)
		debconf_toggle='Scroll Lock key';;
	    grp:switch)
		debconf_switch='Right Alt (AltGr)';;
	    grp:toggle)
		debconf_toggle='Right Alt (AltGr)';;
	    grp:win_switch)
		debconf_switch='Both Logo keys';;
	    lv3:ralt_alt)
		debconf_altgr='No AltGr key';;
	    lv3:alt_switch)
		debconf_altgr='Both Alt keys';;
	    lv3:enter_switch)
		debconf_altgr='Keypad Enter key';;
	    lv3:lalt_switch)
		debconf_altgr='Left Alt';;
	    lv3:lwin_switch)
		debconf_altgr='Left Logo key';;
	    lv3:menu_switch)
		debconf_altgr='Menu key';;
	    lv3:ralt_switch)
		debconf_altgr='Right Alt (AltGr)';;
	    lv3:rwin_switch)
		debconf_altgr='Right Logo key';;
	    lv3:switch)
		debconf_altgr='Right Control';;
	    lv3:win_switch)
		debconf_altgr='Both Logo keys';;
	    terminate:ctrl_alt_bksp)
		debconf_ctrl_alt_bksp=true;;
	    grp_led:scroll)
		;;
	    *)
		unsupported_options=yes
		;;
	esac
    done
fi

# Store the default values for the options into debconf db.  Notice we
# do not store the default values for the model, the layout and the
# variant since the respective questions are asked by the function
# ask_debconf and it takes care to store in debconf db the reqired text.
db_default keyboard-configuration/toggle "$debconf_toggle"
db_default keyboard-configuration/switch "$debconf_switch"
db_default keyboard-configuration/altgr "$debconf_altgr"
db_default keyboard-configuration/compose "$debconf_compose"
db_default keyboard-configuration/ctrl_alt_bksp "$debconf_ctrl_alt_bksp"

#######################################################################
#     Ask the Debconf questions starting from STATE=1.
#######################################################################

# At this point if unsupported_layout=yes, then the values of
# XKBLAYOUT and XKBVARIANT are relevant.  Otherwise the values of
# debconf_layout and debconf_variant have to be used.  Notice the
# difference between these variables - for example when
# XKBLAYOUT=us,el we have debconf_layout=el.

# Notice that the user may choose to disregard the fact that the
# configuration is unsupported (question unsupported_config_layout).
# Because of this, at this point we have to have sensible values for
# debconf_layout and debconf_variant even when unsupported_layout=yes.

STATE=1
old_state=0
while :; do
    starting_state=$STATE
    case "$STATE" in
	1)
	    if [ "$is_debian_installer" ]; then
		# do not ask model question in Debian installer
		db_set keyboard-configuration/modelcode "$debconf_model"
		db_fset keyboard-configuration/model seen true
		# skip the question without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
	    else
		if \
		    ask_debconf keyboard-configuration/model $model_priority \
		        model "$debconf_model"
		then
		    debconf_model="$RET"
		    db_set keyboard-configuration/modelcode "$RET"
		    STATE=$(($STATE + 1))
		else
		    STATE=$(($STATE - 1))
		fi
	    fi
	    ;;
	2)
	    if \
		$detect_keyboard \
		&& [ "$XKBMODEL" != SKIP ] \
		&& [ -e "/usr/share/console-setup-mini/$XKBMODEL.tree" ]
	    then
		db_input high console-setup/ask_detect || true
		if db_go; then
		    STATE=$(($STATE + 1))
		else
		    STATE=$(($STATE - 1))
		fi
	    else
		STATE=$(($STATE + $STATE - $old_state))
	    fi
	    ;;
	3)
	    if \
		[ "$STATE" -ge "$old_state" ] \
		&& $detect_keyboard \
		&& [ "$XKBMODEL" != SKIP ] \
		&& [ -e "/usr/share/console-setup-mini/$XKBMODEL.tree" ] \
		&& db_get console-setup/ask_detect \
		&& [ "$RET" = true ]
	    then
		db_subst console-setup/detect FILENAME \
		    "/usr/share/console-setup-mini/$XKBMODEL.tree"
		if db_input critical console-setup/detect && db_go; then
		    db_get console-setup/detect
		    detected_keyboard="$RET"
		    # TODO: produce human-readable layout name
		    db_subst console-setup/detected LAYOUT "$detected_keyboard"
		    db_input high console-setup/detected || true
		    if db_go; then
			unsupported_layout=no
			STATE=$(($STATE + 1))
		    else
			detected_keyboard=
			STATE=$(($STATE - 1))
		    fi
		else
		    STATE=$(($STATE - 1))
		fi
	    else
		detected_keyboard=
		STATE=$(($STATE + $STATE - $old_state))
	    fi
	    ;;
	4)
	    if [ "$detected_keyboard" ] || [ "$XKBMODEL" = SKIP ]; then
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif [ "$unsupported_layout" = yes ]; then
                # For the question about the keeping of the
                # unsupported configuration we use two different
                # Debconf templates depending on whether the
                # unsupported layout/variant combination has been
                # taken from existing configuration file (obviously in
                # this case the admin is responsible) or it has been
                # computed based on the system configuration such as
                # the locale or xorg.conf (in which case the user may
                # be unaware).
		if [ -f $CONFIGFILE ]; then
                    template=keyboard-configuration/unsupported_config_layout
                else
                    template=keyboard-configuration/unsupported_layout
		    case "$XKBVARIANT" in
		        ,|,,|,,,|'')
		            db_subst $template XKBLAYOUTVARIANT "$XKBLAYOUT"
			    ;;
		        *)
		            db_subst $template XKBLAYOUTVARIANT \
                                "$XKBLAYOUT/$XKBVARIANT"
			    ;;
		    esac
                fi
		db_subst $template XKBLAYOUT "$XKBLAYOUT"
		db_subst $template XKBVARIANT "$XKBVARIANT"
		db_input medium $template || true
		if db_go; then
		    STATE=$(($STATE + 1))
		else
                    # The following code is for the following
                    # situation: admin creates unsupported
                    # configuration, then asks c-s not to keep this
                    # configuration (i.e. gives answer 'no' to this
                    # question), then restores by hand the unsupported
                    # configuration.  Un upgrade the old answer to
                    # this question will be remembered by Debconf so
                    # c-s will overwrite the configuration.  See #729321.
		    db_reset $template || true
		    db_fset $template seen false
		    STATE=$(($STATE - 1))
		fi
		db_get $template
		if [ "$RET" != true ]; then
		    unsupported_layout=no
		fi
	    else
                # The following code is for the following situation:
                # first admin configures unsupported configuration,
                # then gives answer to keep the configuration.  After
                # that admin configures (by hand) a supported
                # configuration.  And after that again unsupported.
                # In this case we want the question about unsupported
                # layout to be asked again.
		db_reset keyboard-configuration/unsupported_config_layout || true
		db_fset keyboard-configuration/unsupported_config_layout seen false
		db_reset keyboard-configuration/unsupported_layout || true
		db_fset keyboard-configuration/unsupported_layout seen false
		# skip the question without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
	    fi
	    ;;
	5)
	    if [ "$detected_keyboard" ]; then
		XKBLAYOUT="${detected_keyboard%%:*}"
		debconf_layout="$XKBLAYOUT"
		db_set keyboard-configuration/layoutcode "$XKBLAYOUT"
		# skip the question without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif [ "$XKBMODEL" = SKIP ]; then
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif [ "$unsupported_layout" = yes ]; then
		# skip the question without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif \
		ask_debconf keyboard-configuration/layout "$layout_priority" \
		    layout "$debconf_layout"
	    then
		debconf_layout="$RET"
		STATE=$(($STATE + 1)) 
	    else
		# always to the next question
		STATE=$(($STATE + 1))
	    fi
	    ;;
	6)
	    adjust_layout=false
	    if [ "$detected_keyboard" ]; then
		case $detected_keyboard in
		    *:*)
			variant="${detected_keyboard#*:}"
			;;
		    *)
			variant=
			;;
		esac
		debconf_variant="$variant"
		adjust_layout=:
		# skip the question without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif [ "$XKBMODEL" = SKIP ]; then
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif [ "$unsupported_layout" = yes ]; then
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif \
		! ask_debconf keyboard-configuration/variant \
			"$layout_priority" \
			"variant*${debconf_layout}" \
			"$debconf_variant"
	    then
		# skip the previous question
		starting_state=$(($STATE - 1))
		STATE=$(($STATE - 2))
	    else
		debconf_variant="$RET"
		variant="$RET"
		adjust_layout=:
		STATE=$(($STATE + 1))
	    fi

            # Compute $XKBLAYOUT and $XKBVARIANT and store their
            # values in debconf db.
	    if $adjust_layout; then
		case "$debconf_layout" in
		    rs)
			case "$debconf_variant" in
			    latin*)
				XKBLAYOUT=$debconf_layout
				;;
			    *)
				XKBLAYOUT=rs,rs
				;;
			esac
			;;
		    jp)
			case "$debconf_variant" in
			    106|common|OADG109A|nicola_f_bs|'')
				XKBLAYOUT=$debconf_layout
				;;
			    *)
				XKBLAYOUT=jp,jp
				;;
			esac
			;;
		    lt)
			XKBLAYOUT=lt,us
			;;
		    me)
			case "$debconf_variant" in
			    basic|latin*)
				XKBLAYOUT=$debconf_layout
				;;
			    *)
				XKBLAYOUT=me,me
				;;
			esac
			;;
		    af|am|ara|ben|bd|bg|bt|by|et|ge|gh|gr|guj|guru|il|'in'|iq|ir|iku|kan|kh|kz|la|lao|lk|kg|ma|mk|mm|mn|mv|mal|np|ori|pk|ru|scc|sy|syr|tel|th|tj|tam|tib|ua|ug|uz)
	                XKBLAYOUT=us,$debconf_layout
	                ;;
	            *)
	                XKBLAYOUT=$debconf_layout
	                ;;
	        esac
		case "$XKBLAYOUT" in
                    rs,rs)
		        case "$debconf_variant" in
		            yz)
                                XKBVARIANT="latinyz,$debconf_variant" ;;
		            alternatequotes)
                                XKBVARIANT="latinalternatequotes,$debconf_variant" ;;
		            *)
                                XKBVARIANT="latin,$debconf_variant" ;;
		        esac
                        ;;
                    lt,us)
		        case "$debconf_variant" in
		            us)
                                XKBVARIANT="us," ;;
		            *)
                                XKBVARIANT="$debconf_variant,altgr-intl" ;;
		        esac
                        ;;
		    *,*)
                        XKBVARIANT=",$debconf_variant"
                        ;;
		    *)
                        XKBVARIANT="$debconf_variant"
                        ;;
		esac
            fi
	    db_set keyboard-configuration/layoutcode "$XKBLAYOUT"
	    db_set keyboard-configuration/variantcode "$XKBVARIANT"
	    ;;
	7)
	    if \
		[ "$unsupported_options" = yes -a "$is_not_debian_installer" ]
	    then
		if [ -f $CONFIGFILE ]; then
                    template=keyboard-configuration/unsupported_config_options
                else
                    template=keyboard-configuration/unsupported_options
                fi
		db_subst $template XKBOPTIONS "$XKBOPTIONS"
		db_input medium $template || true
		if db_go; then
		    STATE=$(($STATE + 1))
		else
		    db_reset $template || true
		    db_fset $template seen false
		    STATE=$(($STATE - 1))
		fi
		db_get $template
		if [ "$RET" != true ]; then
		    unsupported_options=no
		fi
	    else
		db_reset keyboard-configuration/unsupported_config_options || true
		db_fset keyboard-configuration/unsupported_config_options seen false
		db_reset keyboard-configuration/unsupported_options || true
		db_fset keyboard-configuration/unsupported_options seen false
		# skip the question without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
	    fi
	    ;;
	8)
	    if [ "$unsupported_options" = yes ]; then
		db_set keyboard-configuration/optionscode "$XKBOPTIONS"
		# skip the questions without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
	    elif [ "$XKBMODEL" = SKIP ]; then
		STATE=$(( $STATE + $STATE - $old_state ))
	    else
		caps_allocated=no
		lalt_allocated=no
		lctrl_allocated=no
		lshift_allocated=no
		lwin_allocated=no
		menu_allocated=no
		ralt_allocated=no
		rctrl_allocated=no
		rshift_allocated=no
		rwin_allocated=no

		case "$XKBLAYOUT" in
		    *,*)
                        ;;
		    *)
		        db_set keyboard-configuration/toggle 'No toggling'
		        db_set keyboard-configuration/switch 'No temporary switch'
                        ;;
		esac

		db_beginblock
		case "$XKBLAYOUT" in
		    *,*)
		        db_input high keyboard-configuration/toggle || true
		        if [ "$is_not_debian_installer" ]; then
			    db_input medium keyboard-configuration/switch || true
		        fi
                        ;;
		    *)
		        ;;
		esac
		if [ "$is_not_debian_installer" ]; then
		    db_input medium keyboard-configuration/altgr || true
		    db_input medium keyboard-configuration/compose || true
		fi
		if [ -f /usr/bin/X ]; then
		    db_input medium keyboard-configuration/ctrl_alt_bksp || true
		fi
		db_endblock

		if db_go; then
		    STATE=$(($STATE + 1))
		else
		    STATE=$(($STATE - 1))
		fi

		db_get keyboard-configuration/toggle
		case "$RET" in
		    Caps\ Lock)
		        caps_allocated=yes
		        toggle=caps_toggle;;
		    Right\ Alt*)
		        ralt_allocated=yes
		        toggle=toggle;;
		    Right\ Control)
		        rctrl_allocated=yes
		        toggle=rctrl_toggle;;
		    Right\ Shift)
		        rshift_allocated=yes
		        toggle=rshift_toggle;;
		    Right\ Logo?key)
		        rwin_allocated=yes
		        toggle=rwin_toggle;;
		    Menu?key)
			menu_allocated=yes
			toggle=menu_toggle;;
		    Alt+Shift)
			toggle=alt_shift_toggle;;
		    Control+Shift)
			toggle=ctrl_shift_toggle;;
		    Left\ Control+Left\ Shift)
			toggle=lctrl_lshift_toggle;;
		    Scroll\ Lock\ key)
			toggle=sclk_toggle;;
		    Alt+Caps\ Lock)
			toggle=alt_caps_toggle;;
		    Control+Alt)
			toggle=ctrl_alt_toggle;;
		    Left\ Alt)
		        lalt_allocated=yes
		        toggle=lalt_toggle;;
		    Left\ Control)
		        lctrl_allocated=yes
		        toggle=lctrl_toggle;;
		    Left\ Shift)
		        lshift_allocated=yes
		        toggle=lshift_toggle;;
		    Left\ Logo?key)
		        lwin_allocated=yes
		        toggle=lwin_toggle;;
		    No\ toggling)
		        toggle='';;
		    *)
			echo Unknown toggle key option
			exit 1
			;;
		esac
		if [ "$toggle" ]; then
		    toggle=grp:$toggle
		fi
		
		db_get keyboard-configuration/switch
		switch=''
		case "$RET" in
		    Right\ Alt*)
		        if [ "$ralt_allocated" != yes ]; then
			    switch=switch
			    ralt_allocated=yes
		        fi;;
		    Left\ Alt)
		        if [ "$lalt_allocated" != yes ]; then
			    switch=lswitch
			    lalt_allocated=yes
		        fi;;
		    Right\ Logo?key)
		        if [ "$rwin_allocated" != yes ]; then
			    switch=rwin_switch
			    rwin_allocated=yes
		        fi;;
		    Left\ Logo?key)
		        if [ "$lwin_allocated" != yes ]; then
			    switch=lwin_switch
			    lwin_allocated=yes
		        fi;;
		    Both\ Logo?keys)
		        if \
			    [ "$rwin_allocated" != yes ] \
			    && [ "$lwin_allocated" != yes ]
			then
			    switch=win_switch
			    rwin_allocated=yes
			    lwin_allocated=yes
		        fi;;
		    No\ temporary\ switch)
		        switch='';;
		    *)
			echo Unknown switch key option
			exit 1
			;;
		esac
		if [ "$switch" ]; then
		    switch=grp:$switch
		fi
		
		db_get keyboard-configuration/altgr
		altgr=''
		case "$RET" in
		    The?default?for?the?keyboard?layout)
			altgr='';;
		    No?AltGr?key)
			if [ "$ralt_allocated" != yes ]; then
			    # no need for ralt_allocated=yes
			    altgr=ralt_alt
			fi;;
		    Right?Alt*)
			if [ "$ralt_allocated" != yes ]; then
			    altgr=ralt_switch
			    ralt_allocated=yes
			fi;;
		    Right?Control)
			if [ "$rctrl_allocated" != yes ]; then
			    altgr=switch
			    rctrl_allocated=yes
			fi;;
		    Menu?key)
			if [ "$menu_allocated" != yes ]; then
			    altgr=menu_switch
			    menu_allocated=yes
			fi;;
		    Keypad?Enter?key)
			altgr=enter_switch;;
		    Right?Logo?key)
			if [ "$rwin_allocated" != yes ]; then
			    altgr=rwin_switch
			    rwin_allocated=yes
			fi;;
		    Left?Logo?key)
			if [ "$lwin_allocated" != yes ]; then
			    altgr=lwin_switch
			    lwin_allocated=yes
			fi;;
		    Both?Logo?keys)
			if \
			    [ "$rwin_allocated" != yes ] \
			    && [ "$lwin_allocated" != yes ]
			then
			    altgr=win_switch
			    rwin_allocated=yes
			    lwin_allocated=yes
			fi;;
		    Both?Alt?keys)
			if \
			    [ "$lalt_allocated" != yes ] \
			    && [ "$ralt_allocated" != yes ]
			then
			    altgr=alt_switch
			    ralt_allocated=yes
			    lalt_allocated=yes
			fi;;
		    Left?Alt)
			if [ "$lalt_allocated" != yes ]; then
			    altgr=lalt_switch
			    lalt_allocated=yes
			fi;;
		    *)
			echo Unknown altgr key option
			exit 1
			;;
		esac
		if [ "$altgr" ]; then
		    altgr=lv3:$altgr
		fi

		db_get keyboard-configuration/compose
		compose=''
		case "$RET" in
		    No?compose?key)
			compose='';;
		    Right?Alt*)
			if [ "$ralt_allocated" != yes ]; then
			    compose=ralt
			    ralt_allocated=yes
			fi;;
		    Right?Logo?key)
			if [ "$rwin_allocated" != yes ]; then
			    compose=rwin
			    rwin_allocated=yes
			fi;;
		    Left?Logo?key)
			if [ "$lwin_allocated" != yes ]; then
			    compose=lwin 
			    lwin_allocated=yes
			fi;;
		    Right?Control)
			if [ "$rctrl_allocated" != yes ]; then
			    compose=rctrl 
			    rctrl_allocated=yes
			fi;;
		    Menu?key)
			if [ "$menu_allocated" != yes ]; then
			    compose=menu
			    menu_allocated=yes
			fi;;
		    Caps?Lock)
			if [ "$caps_allocated" != yes ]; then
			    compose=caps
			    caps_allocated=yes
			fi;;
		    *)
			echo Unknown compose key option
			exit 1
			;;
		esac
		if [ "$compose" ]; then
		    compose=compose:$compose
		fi
		
		db_get keyboard-configuration/ctrl_alt_bksp
		if [ "$RET" = true ]; then
		    terminate=terminate:ctrl_alt_bksp
		else
		    terminate=''
		fi
		
		# A fix for #566009
		if [ "$ralt_allocated" = yes -a "$altgr" = lv3:ralt_alt ]; then
		    altgr=''
		fi

		case "$XKBLAYOUT" in
		    *,*)
		        leds=grp_led:scroll;;
		    *)
			leds='';;
		esac
		
		options=$(
		    echo $toggle $switch $altgr $compose $terminate $leds \
			| sed -e 's/^ *//' -e 's/ *$//' -e 's/  */,/g'
		)
		db_set keyboard-configuration/optionscode "$options"
	    fi
	    ;;
	*)
	    break
	    ;;
    esac
    old_state=$starting_state
done

if [ $STATE -eq 0 ]; then
    exit 10
else
    db_set keyboard-configuration/store_defaults_in_debconf_db false
fi

exit 0

Zerion Mini Shell 1.0