Hello community, here is the log from the commit of package kbd for openSUSE:Factory checked in at 2014-09-17 21:23:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kbd (Old) and /work/SRC/openSUSE:Factory/.kbd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kbd" Changes: -------- --- /work/SRC/openSUSE:Factory/kbd/kbd.changes 2014-08-25 11:54:35.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.kbd.new/kbd.changes 2014-09-17 21:23:37.000000000 +0200 @@ -1,0 +2,6 @@ +Thu Sep 4 17:51:54 UTC 2014 - [email protected] + +- added /usr/bin/kbd, a simple userfriedly keymap switcher. + From https://github.com/jnweiger/kbd-wrapper + +------------------------------------------------------------------- New: ---- kbd.pl ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kbd.spec ++++++ --- /var/tmp/diff_new_pack.LGAwP6/_old 2014-09-17 21:23:38.000000000 +0200 +++ /var/tmp/diff_new_pack.LGAwP6/_new 2014-09-17 21:23:38.000000000 +0200 @@ -39,6 +39,7 @@ Source11: fbtest.c Source12: fbtest.8 Source13: guess_encoding.pl +Source14: kbd.pl Source42: convert-kbd-mac.sed Source43: repack_kbd.sh Patch0: kbd-1.15.2-prtscr_no_sigquit.patch @@ -230,6 +231,7 @@ install -m 755 fbtest %{buildroot}/%{_sbindir} install -m 644 %{SOURCE12} %{buildroot}/%{_mandir}/man8/ install -m 755 %{SOURCE13} %{buildroot}/%{_bindir}/guess_encoding +install -m 755 %{SOURCE14} %{buildroot}/%{_bindir}/kbd #UsrMerge mkdir -p %{buildroot}/bin mkdir -p %{buildroot}/sbin @@ -376,6 +378,7 @@ %{_bindir}/unicode_stop %{_bindir}/kbdrate %{_bindir}/guess_encoding +%{_bindir}/kbd %{_bindir}/clrunimap %{_bindir}/getunimap %{_bindir}/outpsfheader ++++++ kbd.pl ++++++ #! /usr/bin/perl -w # # simple script to switch the keyboard language # (c) 2014 [email protected] my $sysconffile = '/etc/sysconfig/keyboard'; my $mapdir = '/usr/share/kbd/keymaps/i386'; my $version = '1.0'; my $what = shift || '-h'; my $v = slurp_sysconf($sysconffile); my $m = find_maps(); my $l = { 'english' => 'us.map', 'german' => 'de-latin1-nodeadkeys.map', 'french' => 'fr-latin1.map', 'spanish' => 'es.map', 'italian' => 'it.map', 'dutch' => 'nl.map', }; for my $k (keys %$l) { # zap non-installed languages from our pretty printed list. delete $l->{$k} unless $m->{$l->{$k}} or $m->{"$l->{$k}.gz"}; } if ($what eq '-h') { print qq{kbd Version $version Usage: $0 [option] [mapping] Available options are: -l list typical language mappings. -a list all maps -h print this usage Specify as a mapping either a language name (seen with -l) or a mapping name (seen with -a). For a mapping name, add a .map suffix. Current keymap: $v->{KEYTABLE} }; exit 0; } if ($what eq '-l') { for my $k (sort keys %$l) { printf "%-10s %s\n", $k, $l->{$k}; } exit 0; } if ($what eq '-a' || $what eq '-m') { my @k = map { $1 if /(.*).map(.gz)?$/ } sort keys %$m; print "current keymap: $v->{KEYTABLE}\n"; print "available keymaps: @k\n"; print "\n\nuse '$0 MAPNAME' to change.\n"; exit 0; } $what = $l->{$what} if $l->{$what}; $what = "$what.gz" if $m->{"$what.gz"}; $what = "$what.map" if $m->{"$what.map"}; $what = "$what.map.gz" if $m->{"$what.map.gz"}; die "$what: keymap not found.\n Try $0 -h\n" unless $m->{$what}; write_sysconf($sysconffile, { 'KEYTABLE' => $what } ); # system("kbd_mode -u"); # switch to unicode. Should be the default anyway. system("loadkeys $what"); # now set the keymap. # FIXME: is that all? # mayb also do: systemctl restart kbd.service exit 0; ################################################################### sub find_maps { my $maps; opendir DIR, $mapdir or die "$0: cannot readdir $mapdir: !$\n"; my @d = grep { -d "$mapdir/$_" && !/^\./ } readdir DIR; closedir DIR; for my $d (@d) { opendir DIR, "$mapdir/$d" or die "$0: cannot readdir $mapdir/$d: !$\n"; my @f = grep { /\.map(.gz)?$/ } readdir DIR; closedir DIR; for my $f (@f) { $maps->{$f} = "$d/$f"; } } return $maps; } sub slurp_sysconf { my ($file) = @_; my $vals; open my $fd, "<", $file or die "$0: cannot read config file $file: $!\n"; while (defined(my $line = <$fd>)) { chomp $line; $vals->{$1} = $2 if $line =~ m{^([A-Z_]+)\s*=\s*"(.*)"}; } close $fd; return $vals; } sub write_sysconf { my ($file, $vals) = @_; my @sysconf = (); open my $fd, "<", $file or die "$0: cannot read config file $file: $!\n"; while (defined(my $line = <$fd>)) { chomp $line; push @sysconf, $line; } close $fd; open $fd, ">", $file or die "$0: cannot write config file $file: $!\n"; for my $line (@sysconf) { if ($line =~ m{^([A-Z_]+)\s*=\s*"(.*)"}) { my ($keyword,$value) = ($1,$2); if (defined $vals->{$keyword}) { $line =~ s{\Q$value\E}{$vals->{$keyword}}; } } print $fd "$line\n"; } close $fd or die "$0: could not write config file $file: $!\n"; } -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
