loadkeys: Add --tkeymap to dump the keymap as text#132
loadkeys: Add --tkeymap to dump the keymap as text#132legionus merged 1 commit intolegionus:masterfrom
--tkeymap to dump the keymap as text#132Conversation
Before this commit, the loadkeys tool enabled to dump a keymap in
various formats (binary, C) but not in its own text format. However,
there are some use cases that require text format:
- reformatting;
- golden test;
- round-trip test;
- convert XKB keymaps and thus replace ckbcomp[^1] (requires the
upcoming XKB support).
Added the `--tkeymap` (short: `-t`) options to the loadkeys tool,
enabling dumping the keymap in *text* format after parsing it.
The output format (shape) can be optionally specified, e.g. `--tkeymap=4`
for a full table.
The option name mirrors the `--bkeymap` option that outputs a *binary*
table, so that option names are consistent: `--{b,t}keymap`.
[^1]: https://manpages.debian.org/buster/console-setup/ckbcomp.1.en.html
Signed-off-by: Pierre Le Marre <dev@wismill.eu>
|
While the shape can be chosen, it will always print the strings and Compose entries. I am not sure what is the best approach here. Also, it seems that shapes 2 and 16 do not roundtrip, e.g. |
Hm. Indeed. Really interesting effect. $ ./dumpkeys -S2 > out.dumpkeys.txt
$ ./loadkeys -u -t2 - < out.dumpkeys.txt > out.loadkeys.txt--- out.dumpkeys.txt 2025-05-31 17:01:32.693525586 +0200
+++ out.loadkeys.txt 2025-05-31 17:06:29.921167687 +0200
@@ -397,2 +397 @@
-keycode 58 = AltGr_Lock
- shift keycode 58 = Caps_Lock
+keycode 58 = AltGr_Lock Caps_Lock
@@ -508 +506,0 @@
- shift control keycode 87 = VoidSymbol
@@ -510 +507,0 @@
- shift alt keycode 87 = VoidSymbol
@@ -512 +508,0 @@
- shift altgr alt keycode 87 = VoidSymbol
@@ -516 +511,0 @@
- shift control keycode 88 = VoidSymbol
@@ -518 +512,0 @@
- shift alt keycode 88 = VoidSymbol
@@ -520 +513,0 @@
- shift altgr alt keycode 88 = VoidSymbol
@@ -527 +519,0 @@
- shift control keycode 99 = VoidSymbol
@@ -533,2 +525 @@
-keycode 104 = Prior
- shift keycode 104 = Scroll_Backward
+keycode 104 = Prior Scroll_Backward
@@ -542,2 +533 @@
-keycode 109 = Next
- shift keycode 109 = Scroll_Forward
+keycode 109 = Next Scroll_ForwardThere seems to be a problem with the processing of VoidSymbol i.e. However that's a different issue and not relevant to adding an option. The patch code seems correct to me. |
|
@legionus there seem to be an issue with CI. |
@wismill Yeah. That's why I'm already merge it. The problem in CI with one test and only on ppc64le. On this test valgrind sometimes fails with a very strange error. I am still looking for ways to solve this. https://gist.github.com/legionus/a6f5eeca4f86d9142d5377158ae420eb |
|
I have added a commit to |
Before this commit, the loadkeys tool enabled to dump a keymap in various formats (binary, C) but not in its own text format. However, there are some use cases that require text format:
Added the
--tkeymap(short:-t) options to the loadkeys tool, enabling dumping the keymap in text format after parsing it.The output format (shape) can be optionally specified, e.g.
--tkeymap=4for a full table.The option name mirrors the
--bkeymapoption that outputs a binary table, so that option names are consistent:--{b,t}keymap.Footnotes
https://manpages.debian.org/buster/console-setup/ckbcomp.1.en.html ↩