diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-08-30 18:50:40 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-08-30 18:50:40 +0000 |
commit | 1defcba73b989b6a28826c563417a7c0fc251052 (patch) | |
tree | 1d5bff21637dc8fb4f21fb9846ef6175c045d3f5 /perl-install/keyboard.pm | |
parent | fb80b8a8984779543f0f0c50d7f6dcb995e0ce96 (diff) | |
download | drakx-1defcba73b989b6a28826c563417a7c0fc251052.tar drakx-1defcba73b989b6a28826c563417a7c0fc251052.tar.gz drakx-1defcba73b989b6a28826c563417a7c0fc251052.tar.bz2 drakx-1defcba73b989b6a28826c563417a7c0fc251052.tar.xz drakx-1defcba73b989b6a28826c563417a7c0fc251052.zip |
no_comment
Diffstat (limited to 'perl-install/keyboard.pm')
-rw-r--r-- | perl-install/keyboard.pm | 90 |
1 files changed, 71 insertions, 19 deletions
diff --git a/perl-install/keyboard.pm b/perl-install/keyboard.pm index 5b59bd2c3..248c095ba 100644 --- a/perl-install/keyboard.pm +++ b/perl-install/keyboard.pm @@ -2,29 +2,80 @@ package keyboard; use diagnostics; use strict; -use vars qw($KMAP_MAGIC %defaultKeyboards %loadKeymap); -use common qw(:system :file); +use common qw(:common :system :file); use run_program; use log; use c; -$KMAP_MAGIC = 0x8B39C07F; +my $KMAP_MAGIC = 0x8B39C07F; -%defaultKeyboards = ( - "de" => "de-latin1", - "fr" => "fr-latin1", - "fi" => "fi-latin1", - "se" => "se-latin1", - "no" => "no-latin1", - "cs" => "cz-lat2", - "tr" => "trq", +my %lang2keyboard = +( + "en" => "us", ); 1; +# [1] = name for loadkeys, [2] = extension for Xmodmap +my @fields = +my %keyboards = ( + "be" => [ __("Belgian"), "be-latin1", "be" ], + "bg" => [ __("Bulgarian"), "bg", "bg" ], + "fr" => [ __("French"), "fr-latin1", "fr" ], + "gr" => [ __("Greek"), "gr-8859_7", "gr" ], + "pt" => [ __("Portuguese"), "pt-latin1", "pt" ], +# the xmodmap.pl has to be fixed to use latin2 keymaps +# "pl" => [ __("Polish"), "pl-latin2", "pl" ], + "sk" => [ __("Slovakian"), "sk-latin2", "sk" ], + "hu" => [ __("Hungarian"), "hu-latin2", "hu" ], + "tr_f" => [ __("Turkish (traditional \"F\" model)"), "tr_f-latin5", "tr_f" ], + "tr_q" => [ __("Turkish (modern \"Q\" model)"), "tr_q-latin5", "tr_q" ], + "cz" => [ __("Czech"), "cz-latin2", "cz" ], + "qc" => [ __("Canadian (Quebec)"), "qc-latin1", "qc" ], + "de" => [ __("German"), "de-latin1", "de" ], + "il" => [ __("Israelian"), "il-8859_8", "il" ], + "ru" => [ __("Russian"), "ru-koi8", "ru" ], + "uk" => [ __("UK keyboard"), "uk-latin1", "uk" ], + "us" => [ __("US keyboard"), "us-latin", "us" ], + "dk" => [ __("Danish"), "dk-latin1", "dk" ], + "is" => [ __("Icelandic"), "is-latin1", "is" ], +"dvorak" => [ __("Dvorak"), "dvorak", "dvorak" ], + "la" => [ __("Latin American"), "la-latin1", "la" ], + "it" => [ __("Italian"), "it-latin1", "it" ], + "sf" => [ __("Swiss (french layout)"), "sf-latin1", "sf" ], + "yu" => [ __("Yugoslavian (latin layout)"), "yu-latin2", "yu" ], + "fi" => [ __("Finnish"), "fi-latin1", "fi" ], + "nl" => [ __("Dutch"), "nl-latin1", "nl" ], + "sg" => [ __("Swiss (german layout)"), "sg-latin1", "sg" ], + "no" => [ __("Norwegian"), "no-latin1", "no" ], + "si" => [ __("Slovenian"), "si-latin1", "si" ], +# the xmodmap.th has to be fixed to use tis620 keymaps +# "th" => [ __("Thai keyboard"), "th", "th" ], +# armenian xmodmap have to be checked... +# "am" => [ __("Armenian"), "am-armscii8", "am" ], +# georgian keyboards have to be written... +#"ge_ru"=>[__("Georgian (\"Russian\" layout)","ge_ru-georgian_academy","ge_ru"], +#"ge_la"=>[__("Georgian ("\Latin\" layout)","ge_la-georgian_academy","ge_ru"], +); + +sub list { map { $_->[0] } values %keyboards } +sub keyboard2text { $keyboards{$_[0]} && $keyboards{$_[0]}[0] } +sub text2keyboard { + my ($t) = @_; + while (my ($k, $v) = each %keyboards) { + lc($v->[0]) eq lc($t) and return $k; + } + die "unknown keyboard $t"; +} + +sub lang2keyboard($) { + local ($_) = @_; + $keyboards{$_} && $_ || $lang2keyboard{$_} || substr($_, 0, 2); +} + sub load($) { my ($keymap) = @_; @@ -54,26 +105,27 @@ sub load($) { log::l("loaded $count keymap tables"); } -sub setup(;$) { +sub setup($) { my ($keyboard) = @_; - my $t; + my $o = $keyboards{$keyboard} or return; - $keyboard ||= $defaultKeyboards{$ENV{LANG}} || "us"; - - my $file = "/usr/share/keymaps/$keyboard.kmap"; + my $file = "/usr/share/keymaps/$o->[1].kmap"; if (-e $file) { - log::l("loading keymap $keyboard"); + log::l("loading keymap $o->[1]"); load(cat_($file)); } + eval { run_program::run('xmodmap', "/usr/share/xmodmap/xmodmap.$o->[2]") }; + $keyboard; } sub write($$) { - my ($prefix, $keymap) = @_; + my ($prefix, $keyboard) = @_; + my $o = $keyboards{$keyboard} or return; local *F; open F, ">$prefix/etc/sysconfig/keyboard" or die "failed to create keyboard configuration: $!"; - print F "KEYTABLE=$keymap\n" or die "failed to write keyboard configuration: $!"; + print F "KEYTABLE=$o->[1]\n" or die "failed to write keyboard configuration: $!"; run_program::rooted($prefix, "dumpkeys > /etc/sysconfig/console/default.kmap") or die "dumpkeys failed"; } |