kbd-xkb: add new pkg

This commit is contained in:
Samir Benmendil 2016-08-27 17:44:03 +01:00
parent aba196749f
commit ccbdbae8f8
4 changed files with 287 additions and 0 deletions

36
kbd-xdg/PKGBUILD Normal file
View File

@ -0,0 +1,36 @@
pkgname=kbd-xkb
pkgver=0.1.6
pkgrel=1
pkgdesc="Keytable files imported from XKB"
arch=('x86_64')
url="http://www.kbd-project.org"
license=('GPL')
depends=('glibc' 'pam' 'kbd')
makedepends=(perl keyboardctl=$pkgver)
source=('xml2lst.pl')
md5sums=('c2fb8f824d5af81df99d9bd962dd721c')
package() {
# Convert X keyboard layouts to console keymaps
mkdir -p ${pkgdir}/usr/share/kbd/keymaps/xkb
perl xml2lst.pl < /usr/share/X11/xkb/rules/base.xml > layouts-variants.lst
while read line; do
XKBLAYOUT=`echo "$line" | cut -d " " -f 1`
echo "$XKBLAYOUT" >> layouts-list.lst
XKBVARIANT=`echo "$line" | cut -d " " -f 2`
ckbcomp "$XKBLAYOUT" "$XKBVARIANT" | gzip > ${pkgdir}/usr/share/kbd/keymaps/xkb/"$XKBLAYOUT"-"$XKBVARIANT".map.gz
done < layouts-variants.lst
# Convert X keyboard layouts (plain, no variant)
while read line; do
ckbcomp "$line" | gzip > ${pkgdir}/usr/share/kbd/keymaps/xkb/"$line".map.gz
done < <(sort -u layouts-list.lst)
# wipe converted layouts which cannot input ASCII (#1031848)
zgrep -L "U+0041" ${pkgdir}/usr/share/kbd/keymaps/xkb/* | xargs rm -f
# Rename the converted default fi (kotoistus) layout (#1117891)
gunzip ${pkgdir}/usr/share/kbd/keymaps/xkb/fi.map.gz
mv ${pkgdir}/usr/share/kbd/keymaps/xkb/fi.map ${pkgdir}/usr/share/kbd/keymaps/xkb/fi-kotoistus.map
gzip ${pkgdir}/usr/share/kbd/keymaps/xkb/fi-kotoistus.map
}

View File

@ -0,0 +1,11 @@
--- kbd-1.15.5/data/keymaps/i386/dvorak/dvorak-es.map.old 2013-05-08 14:58:03.393349828 +0200
+++ kbd-1.15.5/data/keymaps/i386/dvorak/dvorak-es.map 2013-05-08 14:58:20.206415053 +0200
@@ -4,7 +4,7 @@
keymaps 0-2,4,5,6,8-10,12,14
include "linux-with-alt-and-altgr"
-include "euro"
+include "euro.map"
strings as usual
keycode 1 = Escape

9
kbd-xdg/fix-euro2.patch Normal file
View File

@ -0,0 +1,9 @@
--- kbd-1.15.5/data/keymaps/i386/include/euro2.map.old 2013-05-08 15:00:25.917752313 +0200
+++ kbd-1.15.5/data/keymaps/i386/include/euro2.map 2013-05-08 15:00:54.943957367 +0200
@@ -2,5 +2,5 @@
# [Say: "loadkeys euro2" to get Euro and cent with AltGr (right alt)
# on the positions where many keyboards have E and C.
# To get it displayed, use a latin0 (i.e., latin9) font.]
-altgr keycode 18 = currency
+altgr keycode 18 = euro
altgr keycode 46 = cent

231
kbd-xdg/xml2lst.pl Normal file
View File

@ -0,0 +1,231 @@
#!/usr/bin/perl
# converts the <rules>.xml file to the old format <rules>.lst file
#
# Usage:
#
# perl xml2lst.pl < filename.xml > filename.lst
#
# author Ivan Pascal
# modified by Vitezslav Crhonek
$doc = new_document( 0, '');
parse('', $doc);
($reg) = node_by_name($doc, '/xkbConfigRegistry');
@models = node_by_name($reg, 'modelList/model/configItem');
@layouts = node_by_name($reg, 'layoutList/layout/configItem');
@options = node_by_name($reg, 'optionList/group/configItem');
for $i (@layouts) {
($name) = node_by_name($i, 'name');
@variants = node_by_name($i, '../variantList/variant/configItem');
for $v (@variants) {
($variant) = node_by_name($v, 'name');
printf("%s %s\n", text_child($name), text_child($variant));
}
}
sub with_attribute {
local ($nodelist, $attrexpr) = @_;
local ($attr, $value) = split (/=/, $attrexpr);
local ($node, $attrvalue);
if (defined $value && $value ne '') {
$value =~ s/"//g;
foreach $node (@{$nodelist}) {
$attrvalue = node_attribute($node, $attr);
if (defined $attrvalue && $attrvalue eq $value) {
return $node;
}
}
} else {
foreach $node (@{$nodelist}) {
if (! defined node_attribute($node, $attr)) {
return $node;
}
}
}
undef;
}
# Subroutines
sub parse {
local $intag = 0;
my (@node_stack, $parent);
$parent = @_[1];
local ($tag, $text);
while (<>) {
chomp;
@str = split /([<>])/;
shift @str if ($str[0] eq '' || $str[0] =~ /^[ \t]*$/);
while (scalar @str) {
$token = shift @str;
if ($token eq '<') {
$intag = 1;
if (defined $text) {
add_text_node($parent, $text);
undef $text;
}
} elsif ($token eq '>') {
$intag = 0;
if ($tag =~ /^\/(.*)/) { # close tag
$parent = pop @node_stack;
} elsif ($tag =~ /^([^\/]*)\/$/) {
empty_tag($parent, $1);
} else {
if (defined ($node = open_tag($parent, $tag))) {
push @node_stack, $parent;
$parent = $node;
}
}
undef $tag;
} else {
if ($intag == 1) {
if (defined $tag) {
$tag .= ' '. $token;
} else {
$tag = $token;
}
} else {
if (defined $text) {
$text .= "\n" . $token;
} else {
$text = $token;
}
}
}
}
}
}
sub new_document {
$doc = new_node( 0, '', 'DOCUMENT');
$doc->{CHILDREN} = [];
return $doc;
}
sub new_node {
local ($parent_node, $tag, $type) = @_;
my %node;
$node{PARENT} = $parent_node;
$node{TYPE} = $type;
if ($type eq 'COMMENT' || $type eq 'TEXT') {
$node{TEXT} = $tag;
$node{NAME} = $type;
return \%node;
}
local ($tname, $attr) = split(' ', $tag, 2);
$node{NAME} = $tname;
if (defined $attr && $attr ne '') {
my %attr_table;
local @attr_list = split ( /"/, $attr);
local ($name, $value);
while (scalar @attr_list) {
$name = shift @attr_list;
$name =~ s/[ =]//g;
next if ($name eq '');
$value = shift @attr_list;
$attr_table{$name} =$value;
}
$node{ATTRIBUTES} = \%attr_table;
}
return \%node;
}
sub add_node {
local ($parent_node, $node) = @_;
push @{$parent_node->{CHILDREN}}, $node;
local $tname = $node->{NAME};
if (defined $parent_node->{$tname}) {
push @{$parent_node->{$tname}}, $node
} else {
$parent_node->{$tname} = [ $node ];
}
}
sub empty_tag {
local ($parent_node, $tag) = @_;
local $node = new_node($parent_node, $tag, 'EMPTY');
add_node($parent_node, $node);
}
sub open_tag {
local ($parent_node, $tag) = @_;
local $node;
if ($tag =~ /^\?.*/ || $tag =~ /^\!.*/) {
$node = new_node($parent_node, $tag, 'COMMENT');
add_node($parent_node, $node);
undef; return;
} else {
$node = new_node($parent_node, $tag, 'NODE');
$node->{CHILDREN} = [];
add_node($parent_node, $node);
return $node;
}
}
sub add_text_node {
local ($parent_node, $text) = @_;
local $node = new_node($parent_node, $text, 'TEXT');
add_node($parent_node, $node);
}
sub node_by_name {
local ($node, $name) = @_;
local ($tagname, $path) = split(/\//, $name, 2);
my @nodelist;
if ($tagname eq '') {
while ($node->{PARENT} != 0) {
$node = $node->{PARENT};
}
sublist_by_name($node, $path, \@nodelist);
} else {
sublist_by_name($node, $name, \@nodelist);
}
return @nodelist;
}
sub sublist_by_name {
local ($node, $name, $res) = @_;
local ($tagname, $path) = split(/\//, $name, 2);
if (! defined $path) {
push @{$res}, (@{$node->{$tagname}});
return;
}
if ($tagname eq '..' && $node->{PARENT} != 0) {
$node = $node->{PARENT};
sublist_by_name($node, $path, $res);
} else {
local $n;
for $n (@{$node->{$tagname}}) {
sublist_by_name($n, $path, $res);
}
}
}
sub node_attribute {
local $node = @_[0];
if (defined $node->{ATTRIBUTES}) {
return $node->{ATTRIBUTES}{@_[1]};
}
undef;
}
sub text_child {
local ($node) = @_;
local ($child) = node_by_name($node, 'TEXT');
return $child->{TEXT};
}