tools: add option to print full RMLVO elements to rmlvo-to-keymap Since the most common use-case is to provide only some elements of RMLVO, this makes it possible to show what is actually being used in the background based on the built-in defaults. Print this in a format that's mostly JSON-compatible or at least easy to parse, just in case. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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
diff --git a/tools/rmlvo-to-keymap.c b/tools/rmlvo-to-keymap.c
index 4783be7..e090de1 100644
--- a/tools/rmlvo-to-keymap.c
+++ b/tools/rmlvo-to-keymap.c
@@ -39,6 +39,7 @@
static bool verbose = false;
static enum output_format {
+ FORMAT_RMLVO,
FORMAT_KEYMAP,
FORMAT_KCCGST,
FORMAT_KEYMAP_FROM_XKB,
@@ -57,6 +58,8 @@ usage(char **argv)
" Enable verbose debugging output\n"
" --kccgst\n"
" Print a keymap which only includes the KcCGST component names instead of the full keymap\n"
+ " --rmlvo\n"
+ " Print the full RMLVO with the defaults filled in for missing elements\n"
" --from-xkb\n"
" Load the XKB file from stdin, ignore RMLVO options. This option\n"
" must not be used with --kccgst.\n"
@@ -95,6 +98,7 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
enum options {
OPT_VERBOSE,
OPT_KCCGST,
+ OPT_RMLVO,
OPT_FROM_XKB,
OPT_INCLUDE,
OPT_INCLUDE_DEFAULTS,
@@ -108,6 +112,7 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, OPT_VERBOSE},
{"kccgst", no_argument, 0, OPT_KCCGST},
+ {"rmlvo", no_argument, 0, OPT_RMLVO},
{"from-xkb", no_argument, 0, OPT_FROM_XKB},
{"include", required_argument, 0, OPT_INCLUDE},
{"include-defaults", no_argument, 0, OPT_INCLUDE_DEFAULTS},
@@ -136,6 +141,9 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
case OPT_KCCGST:
output_format = FORMAT_KCCGST;
break;
+ case OPT_RMLVO:
+ output_format = FORMAT_RMLVO;
+ break;
case OPT_FROM_XKB:
output_format = FORMAT_KEYMAP_FROM_XKB;
break;
@@ -171,6 +179,16 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
}
static bool
+print_rmlvo(struct xkb_context *ctx, const struct xkb_rule_names *rmlvo)
+{
+ printf("rules: \"%s\"\nmodel: \"%s\"\nlayout: \"%s\"\nvariant: \"%s\"\noptions: \"%s\"\n",
+ rmlvo->rules, rmlvo->model, rmlvo->layout,
+ rmlvo->variant ? rmlvo->variant : "",
+ rmlvo->options ? rmlvo->options : "");
+ return true;
+}
+
+static bool
print_kccgst(struct xkb_context *ctx, const struct xkb_rule_names *rmlvo)
{
struct xkb_component_names kccgst;
@@ -308,7 +326,9 @@ main(int argc, char **argv)
xkb_context_include_path_append(ctx, *path);
}
- if (output_format == FORMAT_KEYMAP) {
+ if (output_format == FORMAT_RMLVO) {
+ rc = print_rmlvo(ctx, &names) ? EXIT_SUCCESS : EXIT_FAILURE;
+ } else if (output_format == FORMAT_KEYMAP) {
rc = print_keymap(ctx, &names) ? EXIT_SUCCESS : EXIT_FAILURE;
} else if (output_format == FORMAT_KCCGST) {
rc = print_kccgst(ctx, &names) ? EXIT_SUCCESS : EXIT_FAILURE;