From 203c1ba6471f9fc4d32cfd4582f4e33219efc54d Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 13 Feb 2024 22:41:54 +0100 Subject: [PATCH] keyboard/altgr: us keyboards converted from X11 symbols Interesting complete modes found in X11/xkb/symbols/us: - drix added in xkeyboard-config-2.29~22 (2019-11-14) - symbolics in xkeyboard-config-2.31~42 (2020-07-27) Manual helper script mkkeyboard-xkb-symbols to list level 3-4 characters from source (some cleanup required). --- keyboard/altgr/drix.eng.inc.pl | 125 ++++++++++++++++++++++++++++ keyboard/altgr/symbolics.eng.inc.pl | 125 ++++++++++++++++++++++++++++ tools/mkkeyboard-xkb-symbols | 119 ++++++++++++++++++++++++++ 3 files changed, 369 insertions(+) create mode 100644 keyboard/altgr/drix.eng.inc.pl create mode 100644 keyboard/altgr/symbolics.eng.inc.pl create mode 100755 tools/mkkeyboard-xkb-symbols diff --git a/keyboard/altgr/drix.eng.inc.pl b/keyboard/altgr/drix.eng.inc.pl new file mode 100644 index 0000000..cdb4f05 --- /dev/null +++ b/keyboard/altgr/drix.eng.inc.pl @@ -0,0 +1,125 @@ +use utf8; +use strict; +use warnings; +use Shiar_Sheet::KeyboardChars 'kbchars'; + +my %rows = ( + '!' => "\N{COMBINING GRAVE ACCENT}", + '#' => "\N{COMBINING CIRCUMFLEX ACCENT}", + '$' => "\N{COMBINING DIAERESIS}", + '%' => "\N{COMBINING RING ABOVE}", + '&' => "\N{COMBINING CEDILLA}", + '~' => "\N{COMBINING TILDE}", + '(' => "\N{COMBINING CARON}", + ')' => "\N{COMBINING DOUBLE ACUTE ACCENT}", + '*' => "\N{COMBINING OGONEK}", + '+' => "\x{2260}", + '-' => "\"", + '0' => "\x{2070}", + '1' => "\xB9", + '2' => "\xB2", + '3' => "\xB3", + '4' => "\x{2074}", + '5' => "\x{2075}", + '6' => "\x{2076}", + '7' => "\x{2077}", + '8' => "\x{2078}", + '9' => "\x{2079}", + '=' => "'", + '@' => "\N{COMBINING ACUTE ACCENT}", + '[' => "{", + ']' => "}", + '^' => "\N{COMBINING MACRON}", + '_' => "\xB1", + '`' => "\xA3", + 'A' => "\x{2190}", + 'a' => "\xE6", + 'B' => "\x{20bf}", + 'b' => "\x{2642}", + 'c' => "\xA9", + 'C' => "\xA2", + 'd' => "\x{394}", + 'D' => "\x{2192}", + 'e' => "\x{20AC}", + 'E' => "\x{20AC}", + 'f' => "\x{192}", + 'F' => "\x{191}", + #'g' => "g", + #'G' => "G", + #'H' => "H", + #'h' => "h", + 'i' => "\x{2018}", + 'I' => "\x{2019}", + 'j' => "\x{201C}", + 'J' => "\x{201D}", + 'k' => "\x{201A}", + 'K' => "\x{201E}", + 'L' => "\x{3BB}", + 'l' => "\xA3", + #'M' => "M", # at : + 'm' => "\xB5", # at ; + #'N' => "N", + 'n' => "\x{26a5}", + 'o' => "\x{153}", + 'O' => "\x{3A9}", + 'P' => "\x{20b1}", + 'p' => "\x{3C0}", + 'q' => "\xF8", + 'Q' => "\xD8", + 'R' => "\x{20bd}", + 'r' => "\xAE", + 's' => "\xDF", + 'S' => "\x{2193}", + 'T' => "\x{3C4}", + 't' => "\x{2122}", + #'u' => "u", + #'U' => "U", + #'V' => "V", + 'v' => "\x{2640}", + 'W' => "\x{2191}", + #'w' => "w", + 'x' => "\xD7", + 'X' => "\xF7", + 'y' => "\xA5", + 'Y' => "\xA5", + 'z' => "\xA7", + 'Z' => "\xB6", + '{' => "\xAB", + '}' => "\xBB", + + '"' => "\x{2030}", # unshifted % + "'" => "~", # unshifted # + #'|' => '×', # unshifted & at BKSL same as x + #'\\'=> '$', # unshifted * at bksl + '|' => "≤", # unshifted < at LSGT + '\\'=> "≥", # unshifted > at lsgt + '<' => "\xB7", # unshifted , + ',' => "\x{2026}", # unshifted . + '>' => "\xB4", # unshifted ; + '.' => "`", # unshifted : + '?' => "\xA6", # unshifted \ + '/' => "|", + ':' => "\xBF", # unshifted ? at M + ';' => "\xA1", # unshifted ! at m +); + +my $groups = kbchars(\%rows); +$groups->{def}{''}{$_} .= ' ext' for qw( ` E Y ); + ++{ + %{$groups}, + version => '1.0', + title => 'Drix', + category => 'latin', + intro => join("\n", + "European Latin layout version 3.1 providing", + 'Unicode characters while pressing AltGr,', + 'developed by Jerome Leclanche', + 'for Linux.', + ), + description => [ + "Drix EU Latin keyboard layout table", + "with the AltGr modifier key: provides miscellaneous symbols", + "and accents for some European languages.", + ], +} diff --git a/keyboard/altgr/symbolics.eng.inc.pl b/keyboard/altgr/symbolics.eng.inc.pl new file mode 100644 index 0000000..fd7caf2 --- /dev/null +++ b/keyboard/altgr/symbolics.eng.inc.pl @@ -0,0 +1,125 @@ +use utf8; +use strict; +use warnings; +use Shiar_Sheet::KeyboardChars 'kbchars'; + +my %rows = ( + '!' => "\xAC", + '"' => "\x{2190}", + '#' => "\xA3", + '$' => "\x{20AC}", + '%' => "\x{2030}", + '&' => "\xA7", + "'" => "\x{2192}", + '(' => "\xB7", + ')' => "\xB0", + '*' => "\x{221E}", + '+' => "\xF7", + ',' => "\x{2264}", + '-' => "\x{2260}", + '.' => "\x{2265}", + '/' => "\x{203D}", + '0' => "\x{2070}", + '1' => "\xB9", + '2' => "\xB2", + '3' => "\xB3", + '4' => "\x{2074}", + '5' => "\x{2075}", + '6' => "\x{2076}", + '7' => "\x{2077}", + '8' => "\x{2078}", + '9' => "\x{2079}", + ':' => "\x{2191}", + ';' => "\x{2193}", + '<' => "\xAB", + '=' => "\xD7", + '>' => "\xBB", + '?' => "\x{2766}", + '@' => "\x{2234}", + '[' => "\x{222A}", + '\\'=> "`", + '|' => "~", + '`' => "\\", + '~' => "|", + ']' => "\x{2282}", + '^' => "\x{221A}", + '_' => "\xB1", + 'A' => "\x{391}", + 'a' => "\x{3B1}", + 'B' => "\x{392}", + 'b' => "\x{3B2}", + 'c' => "\x{3C8}", + 'C' => "\x{3A8}", + 'D' => "\x{394}", + 'd' => "\x{3B4}", + 'E' => "\x{395}", + 'e' => "\x{3B5}", + 'F' => "\x{3A6}", + 'f' => "\x{3C6}", + 'g' => "\x{3B3}", + 'G' => "\x{393}", + 'H' => "\x{397}", + 'h' => "\x{3B7}", + 'i' => "\x{3B9}", + 'I' => "\x{399}", + 'j' => "\x{3BE}", + 'J' => "\x{39E}", + 'k' => "\x{3BA}", + 'K' => "\x{39A}", + 'l' => "\x{3BB}", + 'L' => "\x{39B}", + 'M' => "\x{39C}", + 'm' => "\x{3BC}", + 'n' => "\x{3BD}", + 'N' => "\x{39D}", + 'O' => "\x{39F}", + 'o' => "\x{3BF}", + 'p' => "\x{3C0}", + 'P' => "\x{3A0}", + 'Q' => "\x{2203}", + 'q' => "\x{2200}", + 'R' => "\x{3A1}", + 'r' => "\x{3C1}", + 'S' => "\x{3A3}", + 's' => "\x{3C3}", + 'T' => "\x{3A4}", + 't' => "\x{3C4}", + 'u' => "\x{3B8}", + 'U' => "\x{398}", + 'v' => "\x{3C9}", + 'V' => "\x{3A9}", + 'w' => "\x{2208}", + 'W' => "\x{2209}", + 'x' => "\x{3C7}", + 'X' => "\x{3A7}", + 'Y' => "\x{3A5}", + 'y' => "\x{3C5}", + 'z' => "\x{3B6}", + 'Z' => "\x{396}", + '{' => "\x{2229}", + '}' => "\x{2283}", + + # LSGT (iso key) brackets at TLDE/BKSL inversions + '`' => "\x{230A}", + '~' => "\x{230B}", + '\\'=> "\x{2308}", + '|' => "\x{2309}", +); + ++{ + %{ kbchars(\%rows) }, + version => '1.0', + title => 'US Symbolics', + category => 'specialised/greek', + intro => join("\n", + "A US English extension providing scientific", + 'Unicode characters while pressing AltGr,', + 'developed by Daniele Baisero', + 'for Linux.', + ), + description => [ + "US Symbolics keyboard layout table", + "with the AltGr modifier key: provides Greek letters", + "and symbols for scientific English literature.", + ], +} diff --git a/tools/mkkeyboard-xkb-symbols b/tools/mkkeyboard-xkb-symbols new file mode 100755 index 0000000..a7049fa --- /dev/null +++ b/tools/mkkeyboard-xkb-symbols @@ -0,0 +1,119 @@ +#!/usr/bin/env perl +use 5.014; +use warnings; +use utf8; +use re '/msx'; +use JSON (); +use Data::Dump 'pp'; + +our $VERSION = '1.00'; + +my $symname = eval { + open my $keysymh, '<', 'data/keysymdef.json' or die $!; + local $/; + return JSON->new->decode(readline $keysymh); +} or die "Could not read keysym definitions: $@\n"; + +my %geochar = ( + TLDE => ["`", "~"], + AE01 => ['1', "!"], + AE02 => ['2', "\@"], + AE03 => ['3', "#"], + AE04 => ['4', "\$"], + AE05 => ['5', "%"], + AE06 => ['6', "^"], + AE07 => ['7', "&"], + AE08 => ['8', "*"], + AE09 => ['9', "("], + AE10 => ['0', ")"], + AE11 => ["-", "_"], + AE12 => ["=", "+"], + + AD01 => ["q", "Q"], + AD02 => ["w", "W"], + AD03 => ["e", "E"], + AD04 => ["r", "R"], + AD05 => ["t", "T"], + AD06 => ["y", "Y"], + AD07 => ["u", "U"], + AD08 => ["i", "I"], + AD09 => ["o", "O"], + AD10 => ["p", "P"], + AD11 => ["[", "{"], + AD12 => ["]", "}"], + + AC01 => ["a", "A"], + AC02 => ["s", "S"], + AC03 => ["d", "D"], + AC04 => ["f", "F"], + AC05 => ["g", "G"], + AC06 => ["h", "H"], + AC07 => ["j", "J"], + AC08 => ["k", "K"], + AC09 => ["l", "L"], + AC10 => [";", ":"], + AC11 => ["'", '"'], + + LSGT => ["§", "±"], # mac + AB01 => ["z", "Z"], + AB02 => ["x", "X"], + AB03 => ["c", "C"], + AB04 => ["v", "V"], + AB05 => ["b", "B"], + AB06 => ["n", "N"], + AB07 => ["m", "M"], + AB08 => [",", "<"], + AB09 => [".", ">"], + AB10 => ["/", "?"], + BKSL => ["\\","|"], +); + +my %res; +while (readline) { + my ($pos, $def) = m/^\h* key \h+ <(\w+)> \h+ \{ (.+?) \};/ or next; + my @mode = map { [split /,\h*/] } $def =~ m/\[ \h* (.*?) \h* \]/g; + for my $shift (0, 1) { + defined(my $chr = $mode[0]->[$shift + 2]) + or warn "missing $pos +$shift\n"; + if ($chr =~ m/^U ([A-F0-9]+) $/) { + $chr = chr hex $1; + } + elsif (defined $symname->{$chr}) { + $chr = $symname->{$chr}; + } + else { + warn "unknown symbol $chr at $pos\n"; + } + $res{$geochar{$pos}->[$shift] // $pos} = $chr; + #$res{$pos}[$shift] = $symname->{$chr} // $chr; # geochar + } +} +say pp \%res; + +__END__ + +=head1 NAME + +mkkeyboard-xkb-symbols - Character map of an xkb symbols file + +=head1 SYNOPSIS + + cat /usr/share/X11/xkb/symbols/us | + perl -ne 'print if /^xkb_symbols "intl"/../^\};/' | + mkkeyboard-xkb-symbols >map-us-intl.inc.pl + +=head1 DESCRIPTION + +Parses C declarations inside an C section +and returns a perl hash of normalised qwerty input to unicode output +of 3rd and 4th levels (altgr and shift+altgr modes) +to be manually cleaned and integrated in a keyboard page include. + +=head1 AUTHOR + +Mischa POSLAWSKY + +=head1 LICENSE + +Licensed under the GNU Affero General Public License version 3. + -- 2.30.0