File: interactive.c

package info (click to toggle)
libxkbcommon 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,344 kB
  • sloc: ansic: 57,807; xml: 8,905; python: 7,451; yacc: 913; sh: 253; makefile: 23
file content (61 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download
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
/*
 * Copyright © 2025 Pierre Le Marre <dev@wismill.eu>
 * SPDX-License-Identifier: MIT
 */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include "src/utils.h"
#include "tools-common.h"

#ifdef KEYMAP_DUMP
#define TOOL "dump-keymap"
#else
#define TOOL "interactive"
#endif

int
main(int argc, char **argv)
{
    const char *new_argv[64] = {NULL};

    new_argv[0] = select_backend(
#if HAVE_XKBCLI_INTERACTIVE_WAYLAND
        TOOL "-wayland",
#else
        NULL,
#endif
#if HAVE_XKBCLI_INTERACTIVE_X11
        TOOL "-x11",
#else
        NULL,
#endif
#if HAVE_XKBCLI_INTERACTIVE_EVDEV && !defined(KEYMAP_DUMP)
        TOOL "-evdev"
#else
        NULL
#endif
    );

    if (new_argv[0] == NULL) {
        fprintf(
            stderr,
            "ERROR: Unable to find a proper backend for "
#ifdef KEYMAP_DUMP
            "keymap dumping\n"
#else
            "interactive debugging\n"
#endif
        );
        return EXIT_FAILURE;
    }

    for (int k = 1; k < MIN(argc, (int) ARRAY_SIZE(new_argv)); k++) {
        new_argv[k] = argv[k];
    }

    return tools_exec_command("xkbcli", argc, new_argv);
}