#!/bin/sh
set -e
. /usr/share/debconf/confmodule
CONFIGFILE=/etc/default/keyboard
OLDCONFIGFILE=/etc/default/console-setup
default_toggle=''
default_switch=''
default_altgr=''
default_compose=''
default_layout=''
default_variant=''
XKBMODEL=''
XKBLAYOUT=''
XKBVARIANT=''
XKBOPTIONS=''
all_kbdnames () {
cat <<'EOF' 
C*layout*sy*Syria
C*variant*sy**Syria
C*variant*sy*syc_phonetic*Syria - Syriac phonetic
C*variant*sy*syc*Syria - Syriac
C*variant*sy*ku*Syria - Kurdish, Latin Q
C*variant*sy*ku_alt*Syria - Kurdish, Latin Alt-Q
C*variant*sy*ku_f*Syria - Kurdish, (F)
C*layout*se*Sweden
C*variant*se**Sweden
C*variant*se*svdvorak*Sweden - Svdvorak
C*variant*se*dvorak*Sweden - Dvorak
C*variant*se*nodeadkeys*Sweden - Eliminate dead keys
C*variant*se*rus*Sweden - Russian phonetic
C*variant*se*smi*Sweden - Northern Saami
C*variant*se*rus_nodeadkeys*Sweden - Russian phonetic, eliminate dead keys
C*variant*se*mac*Sweden - Macintosh
C*layout*mn*Mongolia
C*variant*mn**Mongolia
C*layout*hu*Hungary
C*variant*hu**Hungary
C*variant*hu*101_qwerty_comma_dead*Hungary - 101/qwerty/comma/Dead keys
C*variant*hu*102_qwerty_dot_dead*Hungary - 102/qwerty/dot/Dead keys
C*variant*hu*101_qwertz_dot_dead*Hungary - 101/qwertz/dot/Dead keys
C*variant*hu*101_qwertz_comma_dead*Hungary - 101/qwertz/comma/Dead keys
C*variant*hu*101_qwertz_dot_nodead*Hungary - 101/qwertz/dot/Eliminate dead keys
C*variant*hu*101_qwerty_comma_nodead*Hungary - 101/qwerty/comma/Eliminate dead keys
C*variant*hu*101_qwerty_dot_dead*Hungary - 101/qwerty/dot/Dead keys
C*variant*hu*101_qwertz_comma_nodead*Hungary - 101/qwertz/comma/Eliminate dead keys
C*variant*hu*nodeadkeys*Hungary - Eliminate dead keys
C*variant*hu*102_qwertz_dot_nodead*Hungary - 102/qwertz/dot/Eliminate dead keys
C*variant*hu*102_qwerty_dot_nodead*Hungary - 102/qwerty/dot/Eliminate dead keys
C*variant*hu*102_qwerty_comma_nodead*Hungary - 102/qwerty/comma/Eliminate dead keys
C*variant*hu*102_qwerty_comma_dead*Hungary - 102/qwerty/comma/Dead keys
C*variant*hu*standard*Hungary - Standard
C*variant*hu*102_qwertz_comma_nodead*Hungary - 102/qwertz/comma/Eliminate dead keys
C*variant*hu*101_qwerty_dot_nodead*Hungary - 101/qwerty/dot/Eliminate dead keys
C*variant*hu*102_qwertz_dot_dead*Hungary - 102/qwertz/dot/Dead keys
C*variant*hu*qwerty*Hungary - qwerty
C*variant*hu*102_qwertz_comma_dead*Hungary - 102/qwertz/comma/Dead keys
C*layout*np*Nepal
C*variant*np**Nepal
C*layout*pk*Pakistan
C*variant*pk**Pakistan
C*variant*pk*ara*Pakistan - Arabic
C*variant*pk*urd-nla*Pakistan - NLA
C*variant*pk*urd-crulp*Pakistan - CRULP
C*layout*gn*Guinea
C*variant*gn**Guinea
C*layout*lk*Sri Lanka
C*variant*lk**Sri Lanka
C*variant*lk*tam_TAB*Sri Lanka - Tamil TAB Typewriter
C*variant*lk*tam_unicode*Sri Lanka - Tamil Unicode
C*layout*kr*Korea, Republic of
C*variant*kr**Korea, Republic of
C*variant*kr*kr104*Korea, Republic of - 101/104 key Compatible
C*layout*cn*China
C*variant*cn**China
C*variant*cn*tib_asciinum*China - Tibetan (with ASCII numerals)
C*variant*cn*tib*China - Tibetan
C*layout*ee*Estonia
C*variant*ee**Estonia
C*variant*ee*dvorak*Estonia - Dvorak
C*variant*ee*nodeadkeys*Estonia - Eliminate dead keys
C*variant*ee*us*Estonia - US keyboard with Estonian letters
C*layout*et*Ethiopia
C*variant*et**Ethiopia
C*layout*za*South Africa
C*variant*za**South Africa
C*layout*mao*Maori
C*variant*mao**Maori
C*layout*am*Armenia
C*variant*am**Armenia
C*variant*am*eastern-alt*Armenia - Alternative Eastern
C*variant*am*western*Armenia - Western
C*variant*am*phonetic-alt*Armenia - Alternative Phonetic
C*variant*am*eastern*Armenia - Eastern
C*variant*am*phonetic*Armenia - Phonetic
C*layout*tm*Turkmenistan
C*variant*tm**Turkmenistan
C*variant*tm*alt*Turkmenistan - Alt-Q
C*layout*latam*Latin American
C*variant*latam**Latin American
C*variant*latam*deadtilde*Latin American - Include dead tilde
C*variant*latam*sundeadkeys*Latin American - Sun dead keys
C*variant*latam*nodeadkeys*Latin American - Eliminate dead keys
C*layout*nec_vndr/jp*Japan (PC-98xx Series)
C*variant*nec_vndr/jp**Japan (PC-98xx Series)
C*layout*ie*Ireland
C*variant*ie**Ireland
C*variant*ie*ogam_is434*Ireland - Ogham IS434
C*variant*ie*CloGaelach*Ireland - CloGaelach
C*variant*ie*ogam*Ireland - Ogham
C*variant*ie*UnicodeExpert*Ireland - UnicodeExpert
C*layout*pt*Portugal
C*variant*pt**Portugal
C*variant*pt*sundeadkeys*Portugal - Sun dead keys
C*variant*pt*nativo-epo*Portugal - Nativo for Esperanto
C*variant*pt*mac_sundeadkeys*Portugal - Macintosh, Sun dead keys
C*variant*pt*mac_nodeadkeys*Portugal - Macintosh, eliminate dead keys
C*variant*pt*nodeadkeys*Portugal - Eliminate dead keys
C*variant*pt*nativo-us*Portugal - Nativo for USA keyboards
C*variant*pt*nativo*Portugal - Nativo
C*variant*pt*mac*Portugal - Macintosh
C*layout*ng*Nigeria
C*variant*ng**Nigeria
C*variant*ng*igbo*Nigeria - Igbo
C*variant*ng*yoruba*Nigeria - Yoruba
C*variant*ng*hausa*Nigeria - Hausa
C*layout*lv*Latvia
C*variant*lv**Latvia
C*variant*lv*tilde*Latvia - Tilde (~) variant
C*variant*lv*fkey*Latvia - F-letter (F) variant
C*variant*lv*apostrophe*Latvia - Apostrophe () variant
C*layout*tr*Turkey
C*variant*tr**Turkey
C*variant*tr*sundeadkeys*Turkey - Sun dead keys
C*variant*tr*ku*Turkey - Kurdish, Latin Q
C*variant*tr*alt*Turkey - Alt-Q
C*variant*tr*ku_alt*Turkey - Kurdish, Latin Alt-Q
C*variant*tr*f*Turkey - (F)
C*variant*tr*ku_f*Turkey - Kurdish, (F)
C*variant*tr*crh_alt*Turkey - Crimean Tatar (Turkish Alt-Q)
C*variant*tr*intl*Turkey - International (with dead keys)
C*variant*tr*crh*Turkey - Crimean Tatar (Turkish Q)
C*variant*tr*crh_f*Turkey - Crimean Tatar (Turkish F)
C*layout*is*Iceland
C*variant*is**Iceland
C*variant*is*dvorak*Iceland - Dvorak
C*variant*is*Sundeadkeys*Iceland - Sun dead keys
C*variant*is*nodeadkeys*Iceland - Eliminate dead keys
C*variant*is*mac*Iceland - Macintosh
C*layout*rs*Serbia
C*variant*rs**Serbia
C*variant*rs*latinyz*Serbia - Latin qwerty
C*variant*rs*latin*Serbia - Latin
C*variant*rs*alternatequotes*Serbia - With guillemets
C*variant*rs*yz*Serbia - Z and ZHE swapped
C*variant*rs*latinunicodeyz*Serbia - Latin Unicode qwerty
C*variant*rs*latinalternatequotes*Serbia - Latin with guillemets
C*variant*rs*latinunicode*Serbia - Latin Unicode
C*layout*gh*Ghana
C*variant*gh**Ghana
C*variant*gh*hausa*Ghana - Hausa
C*variant*gh*ewe*Ghana - Ewe
C*variant*gh*generic*Ghana - Multilingual
C*variant*gh*ga*Ghana - Ga
C*variant*gh*fula*Ghana - Fula
C*variant*gh*akan*Ghana - Akan
C*layout*ma*Morocco
C*variant*ma**Morocco
C*variant*ma*tifinagh-phonetic*Morocco - Tifinagh Phonetic
C*variant*ma*tifinagh-extended-phonetic*Morocco - Tifinagh Extended Phonetic
C*variant*ma*tifinagh-extended*Morocco - Tifinagh Extended
C*variant*ma*tifinagh*Morocco - Tifinagh
C*variant*ma*french*Morocco - French
C*variant*ma*tifinagh-alt-phonetic*Morocco - Tifinagh Alternative Phonetic
C*variant*ma*tifinagh-alt*Morocco - Tifinagh Alternative
C*layout*fo*Faroe Islands
C*variant*fo**Faroe Islands
C*variant*fo*nodeadkeys*Faroe Islands - Eliminate dead keys
C*layout*mv*Maldives
C*variant*mv**Maldives
C*layout*bd*Bangladesh
C*variant*bd**Bangladesh
C*variant*bd*probhat*Bangladesh - Probhat
C*layout*nl*Netherlands
C*variant*nl**Netherlands
C*variant*nl*sundeadkeys*Netherlands - Sun dead keys
C*variant*nl*std*Netherlands - Standard
C*variant*nl*mac*Netherlands - Macintosh
C*layout*br*Brazil
C*variant*br**Brazil
C*variant*br*dvorak*Brazil - Dvorak
C*variant*br*nativo-us*Brazil - Nativo for USA keyboards
C*variant*br*nativo-epo*Brazil - Nativo for Esperanto
C*variant*br*nodeadkeys*Brazil - Eliminate dead keys
C*variant*br*nativo*Brazil - Nativo
C*layout*jp*Japan
C*variant*jp**Japan
C*variant*jp*kana*Japan - Kana
C*variant*jp*OADG109A*Japan - OADG 109A
C*layout*sk*Slovakia
C*variant*sk**Slovakia
C*variant*sk*qwerty*Slovakia - qwerty
C*variant*sk*bksl*Slovakia - Extended Backslash
C*variant*sk*qwerty_bksl*Slovakia - qwerty, extended Backslash
C*layout*cd*Congo, Democratic Republic of the
C*variant*cd**Congo, Democratic Republic of the
C*layout*tj*Tajikistan
C*variant*tj**Tajikistan
C*variant*tj*legacy*Tajikistan - Legacy
C*layout*hr*Croatia
C*variant*hr**Croatia
C*variant*hr*unicodeus*Croatia - US keyboard with Croatian digraphs
C*variant*hr*unicode*Croatia - Use Croatian digraphs
C*variant*hr*alternatequotes*Croatia - Use guillemets for quotes
C*variant*hr*us*Croatia - US keyboard with Croatian letters
C*layout*pl*Poland
C*variant*pl**Poland
C*variant*pl*ru_phonetic_dvorak*Poland - Russian phonetic Dvorak
C*variant*pl*csb*Poland - Kashubian
C*variant*pl*dvorak*Poland - Dvorak
C*variant*pl*dvorak_altquotes*Poland - Dvorak, Polish quotes on key 1
C*variant*pl*dvp*Poland - Programmer Dvorak
C*variant*pl*qwertz*Poland - qwertz
C*variant*pl*dvorak_quotes*Poland - Dvorak, Polish quotes on quotemark key
C*layout*si*Slovenia
C*variant*si**Slovenia
C*variant*si*us*Slovenia - US keyboard with Slovenian letters
C*variant*si*alternatequotes*Slovenia - Use guillemets for quotes
C*layout*il*Israel
C*variant*il**Israel
C*variant*il*biblical*Israel - Biblical Hebrew (Tiro)
C*variant*il*lyx*Israel - lyx
C*variant*il*phonetic*Israel - Phonetic
C*layout*in*India
C*variant*in**India
C*variant*in*urd-phonetic*India - Urdu, Phonetic
C*variant*in*guru*India - Gurmukhi
C*variant*in*guj*India - Gujarati
C*variant*in*bolnagri*India - Hindi Bolnagri
C*variant*in*tam_keyboard_with_numerals*India - Tamil Keyboard with Numerals
C*variant*in*urd-phonetic3*India - Urdu, Alternative phonetic
C*variant*in*jhelum*India - Gurmukhi Jhelum
C*variant*in*kan*India - Kannada
C*variant*in*mal*India - Malayalam
C*variant*in*mal_lalitha*India - Malayalam Lalitha
C*variant*in*tam_unicode*India - Tamil Unicode
C*variant*in*tam*India - Tamil
C*variant*in*ben*India - Bengali
C*variant*in*tam_TSCII*India - Tamil TSCII Typewriter
C*variant*in*tel*India - Telugu
C*variant*in*hin-wx*India - Hindi Wx
C*variant*in*urd-winkeys*India - Urdu, Winkeys
C*variant*in*ori*India - Oriya
C*variant*in*tam_TAB*India - Tamil TAB Typewriter
C*variant*in*ben_probhat*India - Bengali Probhat
C*layout*mt*Malta
C*variant*mt**Malta
C*variant*mt*us*Malta - Maltese keyboard with US layout
C*layout*es*Spain
C*variant*es**Spain
C*variant*es*deadtilde*Spain - Include dead tilde
C*variant*es*dvorak*Spain - Dvorak
C*variant*es*sundeadkeys*Spain - Sun dead keys
C*variant*es*nodeadkeys*Spain - Eliminate dead keys
C*variant*es*cat*Spain - Catalan variant with middle-dot L
C*variant*es*mac*Spain - Macintosh
C*variant*es*ast*Spain - Asturian variant with bottom-dot H and bottom-dot L
C*layout*mk*Macedonia
C*variant*mk**Macedonia
C*variant*mk*nodeadkeys*Macedonia - Eliminate dead keys
C*layout*gb*United Kingdom
C*variant*gb**United Kingdom
C*variant*gb*dvorakukp*United Kingdom - Dvorak (UK Punctuation)
C*variant*gb*dvorak*United Kingdom - Dvorak
C*variant*gb*intl*United Kingdom - International (with dead keys)
C*variant*gb*colemak*United Kingdom - Colemak
C*variant*gb*mac*United Kingdom - Macintosh
C*variant*gb*extd*United Kingdom - Extended - Winkeys
C*layout*ch*Switzerland
C*variant*ch**Switzerland
C*variant*ch*fr_sundeadkeys*Switzerland - French, Sun dead keys
C*variant*ch*fr_mac*Switzerland - French (Macintosh)
C*variant*ch*fr*Switzerland - French
C*variant*ch*fr_nodeadkeys*Switzerland - French, eliminate dead keys
C*variant*ch*de_sundeadkeys*Switzerland - German, Sun dead keys
C*variant*ch*de_nodeadkeys*Switzerland - German, eliminate dead keys
C*variant*ch*de_mac*Switzerland - German (Macintosh)
C*variant*ch*legacy*Switzerland - Legacy
C*layout*az*Azerbaijan
C*variant*az**Azerbaijan
C*variant*az*cyrillic*Azerbaijan - Cyrillic
C*layout*bg*Bulgaria
C*variant*bg**Bulgaria
C*variant*bg*bas_phonetic*Bulgaria - New phonetic
C*variant*bg*phonetic*Bulgaria - Traditional phonetic
C*layout*la*Laos
C*variant*la**Laos
C*layout*lt*Lithuania
C*variant*lt**Lithuania
C*variant*lt*us*Lithuania - US keyboard with Lithuanian letters
C*variant*lt*lekp*Lithuania - LEKP
C*variant*lt*lekpa*Lithuania - LEKPa
C*variant*lt*std*Lithuania - Standard
C*variant*lt*ibm*Lithuania - IBM (LST 1205-92)
C*layout*no*Norway
C*variant*no**Norway
C*variant*no*mac_nodeadkeys*Norway - Macintosh, eliminate dead keys
C*variant*no*dvorak*Norway - Dvorak
C*variant*no*smi_nodeadkeys*Norway - Northern Saami, eliminate dead keys
C*variant*no*nodeadkeys*Norway - Eliminate dead keys
C*variant*no*smi*Norway - Northern Saami
C*variant*no*mac*Norway - Macintosh
C*layout*ca*Canada
C*variant*ca**Canada
C*variant*ca*multi*Canada - Multilingual, first part
C*variant*ca*fr-dvorak*Canada - French Dvorak
C*variant*ca*eng*Canada - English
C*variant*ca*shs*Canada - Secwepemctsin
C*variant*ca*kut*Canada - Ktunaxa
C*variant*ca*multix*Canada - Multilingual
C*variant*ca*multi-2gr*Canada - Multilingual, second part
C*variant*ca*ike*Canada - Inuktitut
C*variant*ca*fr-legacy*Canada - French (legacy)
C*layout*iq*Iraq
C*variant*iq**Iraq
C*variant*iq*ku*Iraq - Kurdish, Latin Q
C*variant*iq*ku_ara*Iraq - Kurdish, Arabic-Latin
C*variant*iq*ku_alt*Iraq - Kurdish, Latin Alt-Q
C*variant*iq*ku_f*Iraq - Kurdish, (F)
C*layout*me*Montenegro
C*variant*me**Montenegro
C*variant*me*cyrillic*Montenegro - Cyrillic
C*variant*me*latinunicode*Montenegro - Latin unicode
C*variant*me*latinyz*Montenegro - Latin qwerty
C*variant*me*latinalternatequotes*Montenegro - Latin with guillemets
C*variant*me*cyrillicyz*Montenegro - Cyrillic, Z and ZHE swapped
C*variant*me*latinunicodeyz*Montenegro - Latin unicode qwerty
C*variant*me*cyrillicalternatequotes*Montenegro - Cyrillic with guillemets
C*layout*th*Thailand
C*variant*th**Thailand
C*variant*th*pat*Thailand - Pattachote
C*variant*th*tis*Thailand - TIS-820.2538
C*layout*ara*Arabic
C*variant*ara**Arabic
C*variant*ara*qwerty*Arabic - qwerty
C*variant*ara*azerty*Arabic - azerty
C*variant*ara*azerty_digits*Arabic - azerty/digits
C*variant*ara*buckwalter*Arabic - Buckwalter
C*variant*ara*qwerty_digits*Arabic - qwerty/digits
C*variant*ara*digits*Arabic - digits
C*layout*epo*Esperanto
C*variant*epo**Esperanto
C*variant*epo*legacy*Esperanto - displaced semicolon and quote (obsolete)
C*layout*ir*Iran
C*variant*ir**Iran
C*variant*ir*ku*Iran - Kurdish, Latin Q
C*variant*ir*ku_ara*Iran - Kurdish, Arabic-Latin
C*variant*ir*pes_keypad*Iran - Persian, with Persian Keypad
C*variant*ir*ku_alt*Iran - Kurdish, Latin Alt-Q
C*variant*ir*ku_f*Iran - Kurdish, (F)
C*layout*by*Belarus
C*variant*by**Belarus
C*variant*by*latin*Belarus - Latin
C*variant*by*legacy*Belarus - Legacy
C*layout*vn*Vietnam
C*variant*vn**Vietnam
C*layout*kg*Kyrgyzstan
C*variant*kg**Kyrgyzstan
C*variant*kg*phonetic*Kyrgyzstan - Phonetic
C*layout*ua*Ukraine
C*variant*ua**Ukraine
C*variant*ua*crh_alt*Ukraine - Crimean Tatar (Turkish Alt-Q)
C*variant*ua*winkeys*Ukraine - Winkeys
C*variant*ua*rstu_ru*Ukraine - Standard RSTU on Russian layout
C*variant*ua*typewriter*Ukraine - Typewriter
C*variant*ua*crh*Ukraine - Crimean Tatar (Turkish Q)
C*variant*ua*crh_f*Ukraine - Crimean Tatar (Turkish F)
C*variant*ua*rstu*Ukraine - Standard RSTU
C*variant*ua*phonetic*Ukraine - Phonetic
C*variant*ua*legacy*Ukraine - Legacy
C*variant*ua*homophonic*Ukraine - Homophonic
C*layout*ru*Russia
C*variant*ru**Russia
C*variant*ru*os_winkeys*Russia - Ossetian, Winkeys
C*variant*ru*legacy*Russia - Legacy
C*variant*ru*phonetic_winkeys*Russia - Phonetic Winkeys
C*variant*ru*dos*Russia - DOS
C*variant*ru*tt*Russia - Tatar
C*variant*ru*os_legacy*Russia - Ossetian, legacy
C*variant*ru*cv_latin*Russia - Chuvash Latin
C*variant*ru*udm*Russia - Udmurt
C*variant*ru*kom*Russia - Komi
C*variant*ru*cv*Russia - Chuvash
C*variant*ru*phonetic*Russia - Phonetic
C*variant*ru*xal*Russia - Kalmyk
C*variant*ru*bak*Russia - Bashkirian
C*variant*ru*typewriter*Russia - Typewriter
C*variant*ru*typewriter-legacy*Russia - Typewriter, legacy
C*variant*ru*sah*Russia - Yakut
C*layout*fi*Finland
C*variant*fi**Finland
C*variant*fi*classic*Finland - Classic
C*variant*fi*nodeadkeys*Finland - Eliminate dead keys
C*variant*fi*smi*Finland - Northern Saami
C*variant*fi*mac*Finland - Macintosh
C*layout*ro*Romania
C*variant*ro**Romania
C*variant*ro*std_cedilla*Romania - Standard (Cedilla)
C*variant*ro*crh_alt*Romania - Crimean Tatar (Turkish Alt-Q)
C*variant*ro*winkeys*Romania - Winkeys
C*variant*ro*crh_dobruca2*Romania - Crimean Tatar (Dobruca-2 Q)
C*variant*ro*std*Romania - Standard
C*variant*ro*crh_f*Romania - Crimean Tatar (Turkish F)
C*variant*ro*crh_dobruca1*Romania - Crimean Tatar (Dobruca-1 Q)
C*variant*ro*cedilla*Romania - Cedilla
C*layout*kz*Kazakhstan
C*variant*kz**Kazakhstan
C*variant*kz*kazrus*Kazakhstan - Kazakh with Russian
C*variant*kz*ruskaz*Kazakhstan - Russian with Kazakh
C*layout*gr*Greece
C*variant*gr**Greece
C*variant*gr*extended*Greece - Extended
C*variant*gr*nodeadkeys*Greece - Eliminate dead keys
C*variant*gr*simple*Greece - Simple
C*variant*gr*polytonic*Greece - Polytonic
C*layout*it*Italy
C*variant*it**Italy
C*variant*it*nodeadkeys*Italy - Eliminate dead keys
C*variant*it*us*Italy - US keyboard with Italian letters
C*variant*it*mac*Italy - Macintosh
C*variant*it*geo*Italy - Georgian
C*layout*de*Germany
C*variant*de**Germany
C*variant*de*dvorak*Germany - Dvorak
C*variant*de*sundeadkeys*Germany - Sun dead keys
C*variant*de*deadgraveacute*Germany - Dead grave acute
C*variant*de*ro*Germany - Romanian keyboard with German letters
C*variant*de*neo*Germany - Neo 2
C*variant*de*deadacute*Germany - Dead acute
C*variant*de*ro_nodeadkeys*Germany - Romanian keyboard with German letters, eliminate dead keys
C*variant*de*mac_nodeadkeys*Germany - Macintosh, eliminate dead keys
C*variant*de*nodeadkeys*Germany - Eliminate dead keys
C*variant*de*dsb*Germany - Lower Sorbian
C*variant*de*qwerty*Germany - qwerty
C*variant*de*dsb_qwertz*Germany - Lower Sorbian (qwertz)
C*variant*de*mac*Germany - Macintosh
C*layout*bt*Bhutan
C*variant*bt**Bhutan
C*layout*be*Belgium
C*variant*be**Belgium
C*variant*be*oss_latin9*Belgium - Alternative, latin-9 only
C*variant*be*sundeadkeys*Belgium - Sun dead keys
C*variant*be*nodeadkeys*Belgium - Eliminate dead keys
C*variant*be*wang*Belgium - Wang model 724 azerty
C*variant*be*iso-alternate*Belgium - ISO Alternate
C*variant*be*oss*Belgium - Alternative
C*variant*be*oss_sundeadkeys*Belgium - Alternative, Sun dead keys
C*layout*brai*Braille
C*variant*brai**Braille
C*variant*brai*left_hand*Braille - Left hand
C*variant*brai*right_hand*Braille - Right hand
C*layout*uz*Uzbekistan
C*variant*uz**Uzbekistan
C*variant*uz*crh_alt*Uzbekistan - Crimean Tatar (Turkish Alt-Q)
C*variant*uz*latin*Uzbekistan - Latin
C*variant*uz*crh*Uzbekistan - Crimean Tatar (Turkish Q)
C*variant*uz*crh_f*Uzbekistan - Crimean Tatar (Turkish F)
C*layout*us*USA
C*variant*us**USA
C*variant*us*dvorak*USA - Dvorak
C*variant*us*alt-intl*USA - Alternative international (former us_intl)
C*variant*us*dvp*USA - Programmer Dvorak
C*variant*us*colemak*USA - Colemak
C*variant*us*dvorak-classic*USA - Classic Dvorak
C*variant*us*dvorak-intl*USA - Dvorak international
C*variant*us*euro*USA - With EuroSign on 5
C*variant*us*olpc2*USA - Group toggle on multiply/divide key
C*variant*us*altgr-intl*USA - International (AltGr dead keys)
C*variant*us*rus*USA - Russian phonetic
C*variant*us*intl*USA - International (with dead keys)
C*variant*us*dvorak-l*USA - Left handed Dvorak
C*variant*us*dvorak-r*USA - Right handed Dvorak
C*variant*us*mac*USA - Macintosh
C*variant*us*chr*USA - Cherokee
C*layout*cz*Czechia
C*variant*cz**Czechia
C*variant*cz*qwerty*Czechia - qwerty
C*variant*cz*ucw*Czechia - UCW layout (accented letters only)
C*variant*cz*qwerty_bksl*Czechia - qwerty, extended Backslash
C*variant*cz*bksl*Czechia - With <\|> key
C*layout*mm*Myanmar
C*variant*mm**Myanmar
C*layout*fr*France
C*variant*fr**France
C*variant*fr*dvorak*France - Dvorak
C*variant*fr*oss_latin9*France - Alternative, latin-9 only
C*variant*fr*sundeadkeys*France - Sun dead keys
C*variant*fr*oss_nodeadkeys*France - Alternative, eliminate dead keys
C*variant*fr*bepo*France - Bepo, ergonomic, Dvorak way
C*variant*fr*latin9_nodeadkeys*France - (Legacy) Alternative, eliminate dead keys
C*variant*fr*geo*France - Georgian AZERTY Tskapo
C*variant*fr*bepo_latin9*France - Bepo, ergonomic, Dvorak way, latin-9 only
C*variant*fr*nodeadkeys*France - Eliminate dead keys
C*variant*fr*latin9*France - (Legacy) Alternative
C*variant*fr*latin9_sundeadkeys*France - (Legacy) Alternative, Sun dead keys
C*variant*fr*bre*France - Breton
C*variant*fr*oss*France - Alternative
C*variant*fr*oci*France - Occitan
C*variant*fr*oss_sundeadkeys*France - Alternative, Sun dead keys
C*variant*fr*mac*France - Macintosh
C*layout*ba*Bosnia and Herzegovina
C*variant*ba**Bosnia and Herzegovina
C*variant*ba*unicode*Bosnia and Herzegovina - Use Bosnian digraphs
C*variant*ba*us*Bosnia and Herzegovina - US keyboard with Bosnian letters
C*variant*ba*unicodeus*Bosnia and Herzegovina - US keyboard with Bosnian digraphs
C*variant*ba*alternatequotes*Bosnia and Herzegovina - Use guillemets for quotes
C*layout*ge*Georgia
C*variant*ge**Georgia
C*variant*ge*ru*Georgia - Russian
C*variant*ge*mess*Georgia - MESS
C*variant*ge*ergonomic*Georgia - Ergonomic
C*variant*ge*os*Georgia - Ossetian
C*layout*kh*Cambodia
C*variant*kh**Cambodia
C*layout*af*Afghanistan
C*variant*af**Afghanistan
C*variant*af*olpc-ps*Afghanistan - OLPC Pashto
C*variant*af*ps*Afghanistan - Pashto
C*variant*af*olpc-uz*Afghanistan - OLPC Southern Uzbek
C*variant*af*uz*Afghanistan - Southern Uzbek
C*variant*af*olpc-fa*Afghanistan - OLPC Dari
C*layout*dk*Denmark
C*variant*dk**Denmark
C*variant*dk*mac_nodeadkeys*Denmark - Macintosh, eliminate dead keys
C*variant*dk*dvorak*Denmark - Dvorak
C*variant*dk*nodeadkeys*Denmark - Eliminate dead keys
C*variant*dk*mac*Denmark - Macintosh
C*layout*sn*Senegal
C*variant*sn**Senegal
C*layout*ad*Andorra
C*variant*ad**Andorra
C*layout*al*Albania
C*variant*al**Albania
EOF
[ ! -f /usr/share/console-setup-mini/kbdnames.gz ] || zcat /usr/share/console-setup-mini/kbdnames.gz 
}
db_capb backup
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'
}
ask_debconf () {
local template priority prefix default_code default_description choices add
template="$1"
priority="$2"
prefix="$(echo "$3"|regex_pattern_escape)"
default_code="$(echo "$4"|regex_pattern_escape)"
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
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
priority=critical
fi
db_input $priority $template || true
db_go || return 255
db_get $template
else
[ $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
}
guess_arch () {
local arch subarch line
if type 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
}
keyboard_present () {
local kern kbdpattern class subclass protocol
kern=`uname -r`
case "$kern" in
1*|2.0*|2.1*|2.2*|2.3*|2.4*|2.5*)
return 0; 
;;
esac
[ -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"
if grep -i "$kbdpattern" /proc/bus/input/devices >/dev/null; then
return 0
fi
[ -d /sys/bus/usb/devices ] || return 0
for d in /sys/bus/usb/devices/*:*; do
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
return 1
}
if type 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
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)
! type iconv >/dev/null || \
kbdnames="$(echo "$kbdnames" |
iconv -f UTF-8 -t $(locale charmap)//TRANSLIT)"
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_old
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_old 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
;;
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=critical
case "$locale" in
*_AL*)
XKBLAYOUT=al  # Albania
;;
*_AZ*)
XKBLAYOUT=az  # Azerbaijan
;;
*_BD*)
XKBLAYOUT=us,bd  # Bangladesh
;;
*_BE*)
XKBLAYOUT=be  # Belgium
;;
*_BG*)
XKBLAYOUT=us,bg  # Bulgaria
XKBVARIANT=,bds
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
XKBVARIANT=de # German
;;
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
;;
ca_ES*)
XKBLAYOUT=es  # Spain
XKBVARIANT=cat # Catalan
;;
*_ES*)
XKBLAYOUT=es  # Spain
;;
*_ET*)
XKBLAYOUT=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
;;
*_KP*)
XKBLAYOUT=kr  # Korea
;;
*_KZ*)
XKBLAYOUT=us,kz  # Kazakhstan
;;
*_LK*)
XKBLAYOUT=us,lk  # Sri Lanka
;;
*_MA*)
XKBLAYOUT=us,ma  # Morocco
;;
*_MK*)
XKBLAYOUT=us,mk  # Macedonia
;;
*_NL*)
XKBLAYOUT=us  # Netherlands
;;
*_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
;;
*_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
;;
*_TJ*)
XKBLAYOUT=us,tj  # Tajikistan
;;
*_TH*)
XKBLAYOUT=us,th  # Thailand
layout_priority=critical
;;
*_TR*)
XKBLAYOUT=tr  # Turkish
layout_priority=critical
;;
*_UA*)
XKBLAYOUT=us,ua  # Ukraine
;;
en_US*)
XKBLAYOUT=us  # U.S. English
;;
*_VN*)
XKBLAYOUT=vn  # Vietnam
;;
*_ZA*)
XKBLAYOUT=za  # South Africa
;;
*_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=gr  # Greece
;;
eo|eo.*|eo_*|eo\@*)
XKBLAYOUT=epo  # Esperanto
layout_priority=critical
;;
fr_*)
XKBLAYOUT=fr  # France
XKBVARIANT=latin9
layout_priority=critical
;;
gu_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,guj # Gujarati
;;
hi_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,deva # Devanagari
;;
hr_*)
XKBLAYOUT=hr  # Croatia
;;
hy_*)
XKBLAYOUT=us,am  # Armenia
;;
ka_*)
XKBLAYOUT=us,ge  # Georgia
layout_priority=critical
;;
kn_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,kan # Kannada
;;
lo_*)
XKBLAYOUT=us,la  # Laos
;;
ml_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,mal # Malayalam
;;
pa_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,guru # Gurmukhi
;;
si_*)
XKBLAYOUT=us,si  # Sri Lanka
XKBVARIANT=,sin_phonetic # Sinhala
;;
sr_*)
XKBLAYOUT=cs,cs  # Serbia and Montenegro
XKBVARIANT=latin,basic
layout_priority=critical
;;
sv_*)
XKBLAYOUT=se  # Sweden
XKBVARIANT=basic
;;
ta_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,tam # Tamil
;;
te_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,tel # Telugu
;;
zh_*)
XKBLAYOUT=cn  # Chinese
;;
*)
XKBLAYOUT=us
;;
esac
if db_get keyboard-configuration/modelcode && [ "$RET" ]; then
XKBMODEL="$RET"
fi
if db_get keyboard-configuration/layoutcode && [ "$RET" ]; then
XKBLAYOUT="$RET"
fi
if db_get keyboard-configuration/variantcode && [ "$RET" ]; then
XKBVARIANT="$RET"
fi
if db_get keyboard-configuration/optionscode && [ "$RET" ]; then
XKBOPTIONS="$RET"
fi
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";;
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="cs,cs"; XKBVARIANT="latin,basic" ;;
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
if \
[ -f /etc/X11/xorg.conf -a ! -e $CONFIGFILE ] \
&& type 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 ~ /^[^()]+\([^()]+\)$/) {
split($1, s, /[()]/);
print "XKBLAYOUT=" s[1];
print "XKBVARIANT=" s[2];
}
}
}
'
eval $(awk "$awk_expr" < /etc/X11/xorg.conf)
fi
if [ -e $OLDCONFIGFILE ]; then
. $OLDCONFIGFILE || true
fi
if [ -e $CONFIGFILE ]; then
. $CONFIGFILE || true
fi
XKBMODEL=$(echo $XKBMODEL | sed 's/ *//g')
XKBLAYOUT=$(echo $XKBLAYOUT | sed 's/ *//g')
XKBVARIANT=$(echo $XKBVARIANT | sed 's/ *//g')
if [ "$XKBLAYOUT" ]; then
case "$XKBLAYOUT" in
lt,lt)
default_layout="${XKBLAYOUT%,*}"
default_variant="${XKBVARIANT%,*}"
unsupported_layout=no
;;
jp,jp|us,jp)
default_layout="${XKBLAYOUT#*,}"
default_variant="${XKBVARIANT#*,}"
unsupported_layout=no
;;
cs,cs|us,am|us,af|us,ara|us,ben|us,bd|us,bg|us,bt|us,by|us,deva|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,ua|us,uz)
if [ "${XKBVARIANT%,*}" = '' ]; then
default_layout="${XKBLAYOUT#*,}"
default_variant="${XKBVARIANT#*,}"
unsupported_layout=no
else
unsupported_layout=yes
fi
;;	    
*,*)
unsupported_layout=yes
;;
*)
default_layout="$XKBLAYOUT"
default_variant="$XKBVARIANT"
;;
esac
fi
if \
! echo "$kbdnames" \
| grep "variant[*]$default_layout[*]$default_variant[*]" >/dev/null
then
unsupported_layout=yes
default_variant=''
if \
! echo "$kbdnames" \
| grep "layout[*]$default_layout[*]" >/dev/null
then
default_layout=us
fi
fi
if [ "$default_layout" = bg -a -z "$default_variant" ]; then
default_variant=bds
[ "$layout_priority" = critical ] || layout_priority=high
fi
default_toggle='Alt+Shift'
default_switch='No temporary switch'
default_altgr='The default for the keyboard layout'
default_compose='No compose key'
default_ctrl_alt_bksp=false
if [ "$XKBOPTIONS" ]; then
default_toggle='No toggling'
default_switch='No temporary switch'
default_altgr='The default for the keyboard layout'
default_compose='No compose key'
for option in `echo $XKBOPTIONS | sed 's/,/ /g'`; do
case "$option" in
compose:caps)
default_compose='Caps Lock';;
compose:lwin)
default_compose='Left Logo key';;
compose:menu)
default_compose='Menu key';;
compose:ralt)
default_compose='Right Alt (AltGr)';;
compose:rctrl)
default_compose='Right Control';;
compose:rwin)
default_compose='Right Logo key';;
grp:alt_caps_toggle)
default_toggle='Alt+Caps Lock';;
grp:alt_shift_toggle)
default_toggle='Alt+Shift';;
grp:caps_toggle)
default_toggle='Caps Lock';;
grp:ctrl_alt_toggle)
default_toggle='Control+Alt';;
grp:ctrl_shift_toggle)
default_toggle='Control+Shift';;
grp:lalt_toggle)
default_toggle='Left Alt';;
grp:lctrl_lshift_toggle)
default_toggle='Left Control+Left Shift';;
grp:lctrl_toggle)
default_toggle='Left Control';;
grp:lshift_toggle)
default_toggle='Left Shift';;
grp:lswitch)
default_switch='Left Alt';;
grp:lwin_switch)
default_switch='Left Logo key';;
grp:lwin_toggle)
default_toggle='Left Logo key';;
grp:menu_toggle)
default_toggle='Menu key';;
grp:rctrl_toggle)
default_toggle='Right Control';;
grp:rshift_toggle)
default_toggle='Right Shift';;
grp:rwin_switch)
default_switch='Right Logo key';;
grp:rwin_toggle)
default_toggle='Right Logo key';;
grp:sclk_toggle)
default_toggle='Scroll Lock key';;
grp:switch)
default_switch='Right Alt (AltGr)';;
grp:toggle)
default_toggle='Right Alt (AltGr)';;
grp:win_switch)
default_switch='Both Logo keys';;
lv3:ralt_alt)
default_altgr='No AltGr key';;
lv3:alt_switch)
default_altgr='Both Alt keys';;
lv3:enter_switch)
default_altgr='Keypad Enter key';;
lv3:lalt_switch)
default_altgr='Left Alt';;
lv3:lwin_switch)
default_altgr='Left Logo key';;
lv3:menu_switch)
default_altgr='Menu key';;
lv3:ralt_switch)
default_altgr='Right Alt (AltGr)';;
lv3:rwin_switch)
default_altgr='Right Logo key';;
lv3:switch)
default_altgr='Right Control';;
lv3:win_switch)
default_altgr='Both Logo keys';;
terminate:ctrl_alt_bksp)
default_ctrl_alt_bksp=true;;
grp_led:scroll)
;;
*)
unsupported_options=yes
;;
esac
done
fi
db_default keyboard-configuration/toggle "$default_toggle"
db_default keyboard-configuration/switch "$default_switch"
db_default keyboard-configuration/altgr "$default_altgr"
db_default keyboard-configuration/compose "$default_compose"
db_default keyboard-configuration/ctrl_alt_bksp "$default_ctrl_alt_bksp"
if [ ! "$unsupported_layout" = yes ]
then
if [ -n "$default_variant" ]
then
default_keymap="$default_layout($default_variant)"
else
default_keymap="$default_layout"
fi
fi
db_default keyboard-configuration/xkb-keymap "$default_keymap"
initial_xkbmodel="$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
unsupported_layout=no
XKBLAYOUT=us
default_layout=us
db_fset keyboard-configuration/layout seen false
db_fset keyboard-configuration/variant seen false
fi
if ! keyboard_present; then
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:alt_shift_toggle,grp_led:scroll";;
us) XKBOPTIONS="";;
*) XKBOPTIONS="lv3:ralt_switch";;
esac
fi
db_set keyboard-configuration/optionscode "$XKBOPTIONS"
exit 0
fi
STATE=1
old_state=0
while :; do
starting_state=$STATE
case "$STATE" in
1)
if [ -f /usr/share/console-setup-mini/keyboard ]; then
db_set keyboard-configuration/modelcode "$XKBMODEL"
db_fset keyboard-configuration/model seen true
STATE=$(( $STATE + $STATE - $old_state ))
else
if [ "$XKBMODEL" = unknown ]; then
model_priority=critical
db_fset keyboard-configuration/model seen false
fi
if \
ask_debconf keyboard-configuration/model $model_priority \
model "$XKBMODEL"
then
XKBMODEL="$RET"
db_set keyboard-configuration/modelcode "$RET"
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
fi
;;
2)
if \
[ ! -f /usr/share/console-setup-mini/keyboard -a \
"$unsupported_layout" = yes ]; then
case "$XKBVARIANT" in
,|,,|,,,|'')
unsupported_variant=''
;;
*)
unsupported_variant="/$XKBVARIANT"
;;
esac
if [ -f $CONFIGFILE ]; then
db_subst keyboard-configuration/unsupported_config_layout \
XKBLAYOUT "$XKBLAYOUT"
db_subst keyboard-configuration/unsupported_config_layout \
XKBVARIANT "$XKBVARIANT"
db_input medium keyboard-configuration/unsupported_config_layout \
|| true
if db_go; then 
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
db_get keyboard-configuration/unsupported_config_layout
else
db_subst keyboard-configuration/unsupported_layout \
XKBLAYOUT "$XKBLAYOUT"
db_subst keyboard-configuration/unsupported_layout \
XKBVARIANT "$XKBVARIANT"
db_subst keyboard-configuration/unsupported_layout \
XKBLAYOUTVARIANT "$XKBLAYOUT$unsupported_variant"
db_input medium keyboard-configuration/unsupported_layout || true
if db_go; then 
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
db_get keyboard-configuration/unsupported_layout
fi
if [ "$RET" != true ]; then
unsupported_layout=no
fi
else
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
STATE=$(( $STATE + $STATE - $old_state ))
fi
;;
3)
if [ -f /usr/share/console-setup-mini/keyboard ]; then
db_input critical keyboard-configuration/xkb-keymap || true
if db_go; then 
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
db_get keyboard-configuration/xkb-keymap
keymap="$RET"
layout="${keymap%(*}"
variant="${keymap#$layout}"
variant="${variant%)}"
variant="${variant#(}"
default_layout="$layout"
default_variant="$variant"
db_fset keyboard-configuration/layout seen true
db_fset keyboard-configuration/variant seen true
elif \
[ "$unsupported_layout" = yes \
-o "$default_variant" != other ]
then
layout="$default_layout"
db_set keyboard-configuration/layoutcode "$XKBLAYOUT"
STATE=$(( $STATE + $STATE - $old_state ))
elif \
ask_debconf keyboard-configuration/layout "$layout_priority" \
layout "$default_layout"
then
default_layout="$RET"
layout="$RET"
STATE=$(($STATE + 1)) 
else
STATE=$(($STATE + 1))
fi
;;
4)
db_metaget keyboard-configuration/other description
other="$RET"
RET="$default_variant"
if [ "$unsupported_layout" = yes ]; then
db_set keyboard-configuration/variantcode "$XKBVARIANT"
STATE=$(( $STATE + $STATE - $old_state ))
elif \
[ ! -f /usr/share/console-setup-mini/keyboard ] && \
! ask_debconf keyboard-configuration/variant "$layout_priority" \
"variant*${layout}" "$default_variant" \
"variant*${layout}*other*$other"
then
starting_state=$(($STATE - 1))
STATE=$(($STATE - 2))
elif default_variant="$RET" && [ "$RET" = other ]; then
STATE=$(($STATE - 1))
else
variant="$RET"
case "$layout" in
cs)
case "$variant" in
latin*)
latin=yes
XKBLAYOUT=$layout
;;
*)
latin=no
XKBLAYOUT=cs,cs
;;
esac
;;
jp)
case "$variant" in
106|common|OADG109A|'')
latin=yes
XKBLAYOUT=$layout
;;
*)
latin=no
XKBLAYOUT=jp,jp
;;
esac
;;
lt)
latin=no
XKBLAYOUT=lt,lt
;;
af|am|ara|ben|bd|bg|bt|by|deva|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|ua|uz)
latin=no
XKBLAYOUT=us,$layout
;;
*)
latin=yes
XKBLAYOUT=$layout
;;
esac
db_set keyboard-configuration/layoutcode "$XKBLAYOUT"
if [ "$latin" = yes ]; then
db_set keyboard-configuration/variantcode "$variant"
elif [ "$XKBLAYOUT" = cs,cs ]; then
case "$variant" in
yz)
db_set keyboard-configuration/variantcode \
"latinyz,$variant"
;;
alternatequotes)
db_set keyboard-configuration/variantcode \
"latinalternatequotes,$variant"
;;
*)
db_set keyboard-configuration/variantcode \
"latin,$variant"
;;
esac
elif [ "$XKBLAYOUT" = lt,lt ]; then
case "$variant" in
us)
db_set keyboard-configuration/variantcode "us,"
;;
*)
db_set keyboard-configuration/variantcode "$variant,us"
;;
esac
else
db_set keyboard-configuration/variantcode ",$variant"
fi
STATE=$(($STATE + 1))
fi
;;
5)
if \
[ ! -f /usr/share/console-setup-mini/keyboard \
-a ! "$unsupported_layout" = yes \
-a "$unsupported_options" = yes ]
then
if [ -f $CONFIGFILE ]; then
db_subst keyboard-configuration/unsupported_config_options \
XKBOPTIONS "$XKBOPTIONS"
db_input medium keyboard-configuration/unsupported_config_options \
|| true
if db_go; then 
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
db_get keyboard-configuration/unsupported_config_options
else
db_subst keyboard-configuration/unsupported_options \
XKBOPTIONS "$XKBOPTIONS"
db_input medium keyboard-configuration/unsupported_options || true
if db_go; then 
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
db_get keyboard-configuration/unsupported_options
fi
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
STATE=$(( $STATE + $STATE - $old_state ))
fi
;;
6)
if \
[ "$unsupported_layout" = yes \
-o "$unsupported_options" = yes ]
then
db_set keyboard-configuration/optionscode "$XKBOPTIONS"
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
if [ "$latin" = yes ]; then
db_set keyboard-configuration/toggle 'No toggling'
db_set keyboard-configuration/switch 'No temporary switch'
fi
db_beginblock
if [ "$latin" = no ]; then
db_input high keyboard-configuration/toggle || true
if [ ! -f /usr/share/console-setup-mini/keyboard ]; then
db_input medium keyboard-configuration/switch || true
fi
fi
if [ ! -f /usr/share/console-setup-mini/keyboard ]; 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
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
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
