From 2cb90c958f7efa36b00fe845c38bbe0d00e15b1e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 8 Jul 2020 09:55:20 +1000 Subject: 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 --- tools/rmlvo-to-keymap.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tools') 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; @@ -170,6 +178,16 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names) return true; } +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) { @@ -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; -- cgit v1.2.1