From b828085578158fe94874f39369754fcc5e0113a3 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 7 Mar 2024 19:20:06 +0100 Subject: [PATCH] keyboard/altgr/unigraph: export script mkxkbsymbols --- Makefile | 5 ++- keyboard/altgr/unigraph.eng.inc.pl | 1 + tools/mkxkbsymbols | 56 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 tools/mkxkbsymbols diff --git a/Makefile b/Makefile index df6cbe5..7db808b 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ word/put.js: $(download) word/%.min.js: word/%.js uglifyjs -m '' $< -o $@ -data: data/digraphs.json data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.json data/unicode-sampler word +data: data/digraphs.json data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.json data/unicode-sampler word keyboard/symbols/unigraph data/DerivedAge.txt: $(download) tools/wget-ifmodified http://www.unicode.org/Public/UNIDATA/$(@F) $@ @@ -56,6 +56,9 @@ data/keysymdef.json: tools/mkxkeysymdef data/keysymdef.h data/digraphs-xorg.json: tools/mkdigraphs-xorg data/xorg-compose data/keysymdef.json $(call cmdsave,$^) +keyboard/symbols/%: tools/mkxkbsymbols data/keyboard/altgr/%.eng.json + $(call cmdsave,$^) + data/digraphs-vim.inc.pl: tools/mkdigraphs-vim $(call cmdsave,$<) diff --git a/keyboard/altgr/unigraph.eng.inc.pl b/keyboard/altgr/unigraph.eng.inc.pl index e54badf..89498ff 100644 --- a/keyboard/altgr/unigraph.eng.inc.pl +++ b/keyboard/altgr/unigraph.eng.inc.pl @@ -83,6 +83,7 @@ while (my ($k, $c) = each %rows) { ), 'Inspired by MSX graph mode,', 'but reimagined for modern Unicode coverage.', + 'Freely available as xorg symbols export.', ), moderows => '5421', flag => { diff --git a/tools/mkxkbsymbols b/tools/mkxkbsymbols new file mode 100755 index 0000000..0a24a7f --- /dev/null +++ b/tools/mkxkbsymbols @@ -0,0 +1,56 @@ +#!/usr/bin/env perl +use 5.014; +use warnings; +use utf8; + +use JSON (); + +our $VERSION = '1.00'; + +my $info = eval { + local $/; + return JSON->new->utf8->decode(readline); +} or die "Could not read keyboard layout data: $@\n"; + +my $geochar = do './keyspos.inc.pl' + or die "Could not read keyboard position names: $@\n"; + +if (($info->{moderows} // '') =~ /4/) { + push @{$_}, map {"+$_"} @{$_} for values %{$geochar}; +} + +my ($name) = $ARGV =~ m{.*/([^.]+)}; +say "// setxkbmap -print $name | xkbcomp -w0 -I.. - \$DISPLAY"; +say ''; + +say sprintf 'xkb_symbols "%s" {', $info->{title}; +for my $k (sort keys %{$geochar}) { + printf "\tkey <%s> {[%s]};\n", $k, join(', ', + map { !$_ ? 'NoSymbol' : sprintf 'U%04X', ord } + map { $info->{key}->{$_} } @{ $geochar->{$k} } + ); +} +say '};'; + +=head1 NAME + +mkxkbsymbols - Export keyboard layout metadata as Xorg symbols + +=head1 SYNOPSIS + + tools/mkxkbsymbols data/keyboard/altgr/$NAME.eng.json >$NAME + setxkbmap -print $NAME | xkbcomp -w0 -I.. - $DISPLAY + +=head1 DESCRIPTION + +Converts site includes (back) to I configurations +compatible with C so it can be used in Xorg. + +=head1 AUTHOR + +Mischa POSLAWSKY + +=head1 LICENSE + +Licensed under the GNU Affero General Public License version 3. + -- 2.30.0