Hash :
a83a482c
        
        Author :
  
        
        Date :
2025-07-18T11:27:52
        
      
tools: Add variants with automatic session type detection Added: - `xkbcli-interactive` - `xkbcli-dump-keymap`
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);
}