1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#!/bin/env perl
use strict;
my $origXkbRules;
my $origXkbModel;
my $origXkbLayouts;
my $origXkbOptions;
my $origXkbVariants;
sub backupXkbSettings
{
open (XPROP, "xprop -root |") or die "Could not start xprop";
PROP: while (<XPROP>)
{
if (/_XKB_RULES_NAMES\(STRING\) = \"(.*)\", \"(.*)\", \"(.*)\", \"(.*)\", \"(.*)\"/)
{
( $origXkbRules, $origXkbModel, $origXkbLayouts, $origXkbVariants, $origXkbOptions ) =
( $1, $2, $3, $4, $5 ) ;
last PROP;
}
}
close XPROP;
}
sub setXkbSettings
{
my ( $xkbRules, $xkbModel, $xkbLayouts, $xkbVariants, $xkbOptions ) = @_;
( system ( "setxkbmap",
"-rules", $xkbRules,
"-model", $xkbModel,
"-layout", $xkbLayouts,
"-variant", $xkbVariants,
"-option", $xkbOptions ) == 0 ) or die "Could not set xkb configuration";
}
sub restoreXkbSettings
{
setXkbSettings( $origXkbRules, $origXkbModel, $origXkbLayouts, $origXkbVariants, $origXkbOptions );
}
sub dumpXkbSettings
{
my ( $xkbRules, $xkbModel, $xkbLayouts, $xkbVariants, $xkbOptions ) = @_;
print "rules: [$xkbRules]\n" ;
print "model: [$xkbModel]\n" ;
print "layouts: [$xkbLayouts]\n" ;
print "variants: [$xkbVariants]\n" ;
print "options: [$xkbOptions]\n" ;
}
sub testLevel1
{
my ( $type, $idx ) = @_;
open ( XSLTPROC, "xsltproc --stringparam type $type listCIs.xsl ../rules/base.xml.in |" ) or
die ( "Could not start xsltproc" );
while (<XSLTPROC>)
{
chomp();
if (/(\w+)/)
{
my $paramValue=$1;
print "--- setting $type: [$paramValue]\n";
my @params = ( $origXkbRules, $origXkbModel, $origXkbLayouts, $origXkbVariants, $origXkbOptions );
@params[$idx] = $paramValue;
dumpXkbSettings ( @params );
setXkbSettings ( @params );
}
}
close XSLTPROC;
}
backupXkbSettings();
dumpXkbSettings( $origXkbRules, $origXkbModel, $origXkbLayouts, $origXkbVariants, $origXkbOptions );
testLevel1( "model", 1 );
restoreXkbSettings();
|