diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/.gitignore | 2 | ||||
-rw-r--r-- | tools/Makefile.am | 46 | ||||
-rwxr-xr-x | tools/install-compat-scripts.sh | 9 | ||||
-rw-r--r-- | tools/libinput-debug-events.1 | 8 | ||||
-rw-r--r-- | tools/libinput-debug-events.c | 14 | ||||
-rwxr-xr-x | tools/libinput-debug-events.compat | 4 | ||||
-rw-r--r-- | tools/libinput-list-devices.1 | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/libinput-list-devices.c | 46 | ||||
-rwxr-xr-x | tools/libinput-list-devices.compat | 4 | ||||
-rw-r--r-- | tools/libinput-tool.c | 91 | ||||
-rw-r--r-- | tools/libinput-tool.h | 7 | ||||
-rw-r--r-- | tools/libinput.1 | 115 | ||||
-rw-r--r-- | tools/shared.c | 20 | ||||
-rw-r--r-- | tools/shared.h | 3 |
14 files changed, 139 insertions, 244 deletions
diff --git a/tools/.gitignore b/tools/.gitignore index 2e4c93d..9bdb48d 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1,4 +1,2 @@ event-gui ptraccel-debug -libinput-list-devices -libinput-debug-events diff --git a/tools/Makefile.am b/tools/Makefile.am index 68d1fd4..0702dc6 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,9 +1,12 @@ noinst_PROGRAMS = ptraccel-debug -bin_PROGRAMS = libinput-list-devices libinput-debug-events libinput +bin_PROGRAMS = libinput +toolsdir = $(libexecdir)/libinput +tools_PROGRAMS = +bin_SCRIPTS = libinput-list-devices.compat libinput-debug-events.compat AM_CPPFLAGS = -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ - -I$(top_builddir)/src # for libinput-version.h + -I$(top_builddir)/src # for libinput-version.h AM_CFLAGS = $(GCC_CFLAGS) AM_CXXFLAGS = $(GCC_CXXFLAGS) @@ -15,28 +18,27 @@ ptraccel_debug_SOURCES = ptraccel-debug.c ptraccel_debug_LDADD = ../src/libfilter.la ../src/libinput.la ptraccel_debug_LDFLAGS = -no-install +libinput_SOURCES = \ + libinput-tool.c \ + libinput-tool.h \ + $(shared_sources) +libinput_LDADD = ../src/libinput.la $(LIBUDEV_LIBS) $(LIBEVDEV_LIBS) +libinput_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) $(LIBEVDEV_CFLAGS) \ + -DLIBINPUT_TOOL_PATH="\"@libexecdir@/libinput\"" +dist_man1_MANS = libinput.1 + +tools_PROGRAMS += libinput-list-devices libinput_list_devices_SOURCES = libinput-list-devices.c $(shared_sources) libinput_list_devices_LDADD = ../src/libinput.la $(LIBUDEV_LIBS) $(LIBEVDEV_LIBS) -libinput_list_devices_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) $(LIBEVDEV_CFLAGS) \ - -DTOOLS_BUILD_STANDALONE=1 -dist_man1_MANS = libinput-list-devices.1 +libinput_list_devices_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) $(LIBEVDEV_CFLAGS) +dist_man1_MANS += libinput-list-devices.1 +tools_PROGRAMS += libinput-debug-events libinput_debug_events_SOURCES = libinput-debug-events.c $(shared_sources) libinput_debug_events_LDADD = ../src/libinput.la $(LIBUDEV_LIBS) $(LIBEVDEV_LIBS) -libinput_debug_events_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) $(LIBEVDEV_CFLAGS) \ - -DTOOLS_BUILD_STANDALONE=1 +libinput_debug_events_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) $(LIBEVDEV_CFLAGS) dist_man1_MANS += libinput-debug-events.1 -libinput_SOURCES = \ - libinput-tool.c \ - libinput-tool.h \ - libinput-debug-events.c \ - libinput-list-devices.c \ - $(shared_sources) -libinput_LDADD = ../src/libinput.la $(LIBUDEV_LIBS) $(LIBEVDEV_LIBS) -libinput_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) $(LIBEVDEV_CFLAGS) -dist_man1_MANS += libinput.1 - if BUILD_EVENTGUI noinst_PROGRAMS += event-gui @@ -48,4 +50,12 @@ event_gui_CFLAGS = $(CAIRO_CFLAGS) $(GTK_CFLAGS) \ event_gui_LDFLAGS = -no-install endif -EXTRA_DIST = make-ptraccel-graphs.sh +EXTRA_DIST = make-ptraccel-graphs.sh $(bin_SCRIPTS) + +install-data-hook: + (cd $(DESTDIR)$(bindir) && mv libinput-list-devices.compat libinput-list-devices) + (cd $(DESTDIR)$(bindir) && mv libinput-debug-events.compat libinput-debug-events) + +uninstall-local: + rm -f $(DESTDIR)$(bindir)/libinput-list-devices + rm -f $(DESTDIR)$(bindir)/libinput-debug-events diff --git a/tools/install-compat-scripts.sh b/tools/install-compat-scripts.sh new file mode 100755 index 0000000..0d8b3ad --- /dev/null +++ b/tools/install-compat-scripts.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +# This does not honor $bindir properly, because we cannot get to it +# here. Does anyone build to something but prefix/bin? +# +bindir="${DESTDIR}/${MESON_INSTALL_PREFIX}/bin" +mkdir -p "$bindir" +cp "${MESON_SOURCE_ROOT}/tools/libinput-list-devices.compat" "${bindir}/libinput-list-devices" +cp "${MESON_SOURCE_ROOT}/tools/libinput-debug-events.compat" "${bindir}/libinput-debug-events" diff --git a/tools/libinput-debug-events.1 b/tools/libinput-debug-events.1 index dfc9a45..b0dbc39 100644 --- a/tools/libinput-debug-events.1 +++ b/tools/libinput-debug-events.1 @@ -2,11 +2,11 @@ .SH NAME libinput-debug-events \- debug helper for libinput .SH SYNOPSIS -.B libinput-debug-events [--help] [--show-keycodes] +.B libinput debug-events [--help] [--show-keycodes] .SH DESCRIPTION .PP The -.I libinput-debug-events +.B "libinput debug-events" tool creates a libinput context and prints all events from these devices. .PP This is a debugging tool only, its output may change at any time. Do not @@ -31,3 +31,7 @@ removed at any time. .PP Events shown by this tool may not correspond to the events seen by a different user of libinput. This tool initializes a separate context. +.SH LIBINPUT +Part of the +.B libinput(1) +suite diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c index f64708d..cf29dab 100644 --- a/tools/libinput-debug-events.c +++ b/tools/libinput-debug-events.c @@ -897,7 +897,7 @@ mainloop(struct libinput *li) } int -libinput_debug_events(struct global_options *opts, int argc, char **argv) +main(int argc, char **argv) { struct libinput *li; struct timespec tp; @@ -910,7 +910,7 @@ libinput_debug_events(struct global_options *opts, int argc, char **argv) if (tools_parse_args(argc, argv, &context)) return 1; - be_quiet = context.options.global_options.quiet; + be_quiet = context.options.quiet; li = tools_open_backend(&context); if (!li) @@ -922,13 +922,3 @@ libinput_debug_events(struct global_options *opts, int argc, char **argv) return 0; } - -#if TOOLS_BUILD_STANDALONE -int -main(int argc, char **argv) -{ - struct global_options opts = {0}; - - return libinput_debug_events(&opts, argc, argv); -} -#endif diff --git a/tools/libinput-debug-events.compat b/tools/libinput-debug-events.compat new file mode 100755 index 0000000..dc11af7 --- /dev/null +++ b/tools/libinput-debug-events.compat @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "WARNING: This compatibility wrapper will be removed in the future. Please run 'libinput debug-events' instead" 1>&2 +exec libinput debug-events $@ diff --git a/tools/libinput-list-devices.1 b/tools/libinput-list-devices.1 index 99a66b5..555c0fd 100644 --- a/tools/libinput-list-devices.1 +++ b/tools/libinput-list-devices.1 @@ -2,17 +2,17 @@ .SH NAME libinput-list-devices \- list local devices as recognized by libinput .SH SYNOPSIS -.B libinput-list-devices [--help] +.B libinput list-devices [--help] .SH DESCRIPTION .PP The -.I libinput-list-devices +.B "libinput list-devices" tool creates a libinput context on the default seat "seat0" and lists all devices recognized by libinput. Each device shows available configurations the respective default configuration setting. .PP -For configuration options that allow multiple different settings (e.g. -scrolling), all available settings are listed. The default setting is +For configuration options that allow multiple different settings +(e.g. scrolling), all available settings are listed. The default setting is prefixed by an asterisk (*). .PP This tool usually needs to be run as root to have access to the @@ -32,6 +32,10 @@ driver or the Wayland compositor. .PP An xorg.conf(5) configuration entry or Wayland compositor setting may have changed configurations on a device. The -.I libinput-list-devices +.B "libinput list-devices" tool only shows the device's default configuration, not the current configuration. +.SH LIBINPUT +Part of the +.B libinput(1) +suite diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c index a0154d3..9d6c70b 100644..100755 --- a/tools/libinput-list-devices.c +++ b/tools/libinput-list-devices.c @@ -355,11 +355,7 @@ print_device_notify(struct libinput_event *ev) static inline void usage(void) { -#if TOOLS_BUILD_STANDALONE - printf("Usage: %s [--help|--version]\n", program_invocation_short_name); -#else printf("Usage: libinput list-devices [--help]\n"); -#endif printf("\n" "This tool creates a libinput context on the default seat \"seat0\"\n" "and lists all devices recognized by libinput and the configuration options.\n" @@ -367,26 +363,30 @@ usage(void) "\n" "Options:\n" "--help ...... show this help\n" -#if TOOLS_BUILD_STANDALONE "--version ... show version information\n" -#endif "\n" "This tool requires access to the /dev/input/eventX nodes.\n"); } int -libinput_list_devices(struct global_options *opts, int argc, char **argv) +main(int argc, char **argv) { struct libinput *li; struct tools_context context; struct libinput_event *ev; -#if !TOOLS_BUILD_STANDALONE if (argc > 1) { - usage(); - return streq(argv[1], "--help") ? EXIT_SUCCESS : EXIT_FAILURE; + if (streq(argv[1], "--help")) { + usage(); + return 0; + } else if (streq(argv[1], "--version")) { + printf("%s\n", LIBINPUT_VERSION); + return 0; + } else { + usage(); + return 1; + } } -#endif tools_init_context(&context); @@ -408,27 +408,3 @@ libinput_list_devices(struct global_options *opts, int argc, char **argv) return EXIT_SUCCESS; } - -#if TOOLS_BUILD_STANDALONE -int -main(int argc, char **argv) -{ - struct global_options options = {0}; - - if (argc > 1) { - if (streq(argv[1], "--help")) { - usage(); - return 0; - } else if (streq(argv[1], "--version")) { - printf("%s\n", LIBINPUT_VERSION); - return 0; - } else { - usage(); - return 1; - } - } - - return libinput_list_devices(&options, argc - optind, &argv[optind]); -} - -#endif /* TOOLS_BUILD_STANDALONE */ diff --git a/tools/libinput-list-devices.compat b/tools/libinput-list-devices.compat new file mode 100755 index 0000000..3fe3baa --- /dev/null +++ b/tools/libinput-list-devices.compat @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "WARNING: This compatibility wrapper will be removed in the future. Please run 'libinput list-devices' instead" 1>&2 +exec libinput list-devices $@ diff --git a/tools/libinput-tool.c b/tools/libinput-tool.c index 1485419..32bb0e5 100644 --- a/tools/libinput-tool.c +++ b/tools/libinput-tool.c @@ -63,58 +63,67 @@ libinput_tool_usage(void) "\n"); } -enum command { - COMMAND_NONE, - COMMAND_LIST_DEVICES, - COMMAND_DEBUG_EVENTS, -}; - enum global_opts { GOPT_HELP = 1, GOPT_VERSION, - GOPT_QUIET, - GOPT_VERBOSE, }; +static inline void +setup_path(void) +{ + const char *path = getenv("PATH"); + char new_path[PATH_MAX]; + + snprintf(new_path, + sizeof(new_path), + "%s:%s", + LIBINPUT_TOOL_PATH, + path ? path : ""); + setenv("PATH", new_path, 1); +} + static int -run_args_cmd(enum command cmd, - struct global_options *global_options, - int argc, char *argv[]) +exec_command(int real_argc, char **real_argv) { - optind = 0; - - switch (cmd) { - case COMMAND_NONE: - break; - case COMMAND_LIST_DEVICES: - return libinput_list_devices(global_options, argc, argv); - case COMMAND_DEBUG_EVENTS: - return libinput_debug_events(global_options, argc, argv); + char *argv[64] = {NULL}; + char executable[128]; + const char *command; + int rc; + + assert((size_t)real_argc < ARRAY_LENGTH(argv)); + + command = real_argv[0]; + + rc = snprintf(executable, sizeof(executable), "libinput-%s", command); + if (rc >= (int)sizeof(executable)) { + libinput_tool_usage(); + return EXIT_FAILURE; } + argv[0] = executable; + for (int i = 1; i < real_argc; i++) + argv[i] = real_argv[i]; + + setup_path(); + + rc = execvp(executable, argv); + fprintf(stderr, + "Failed to execute '%s' (%s)\n", + command, + strerror(errno)); return EXIT_FAILURE; } int main(int argc, char **argv) { - enum command cmd = COMMAND_NONE; - const char *command; int option_index = 0; - struct global_options global_options = {0}; - - if (argc == 1) { - libinput_tool_usage(); - return EXIT_FAILURE; - } while (1) { int c; static struct option opts[] = { { "help", no_argument, 0, GOPT_HELP }, { "version", no_argument, 0, GOPT_VERSION }, - { "quiet", no_argument, 0, GOPT_QUIET }, - { "verbose", no_argument, 0, GOPT_VERBOSE }, { 0, 0, 0, 0} }; @@ -130,33 +139,19 @@ main(int argc, char **argv) case GOPT_VERSION: printf("%s\n", LIBINPUT_VERSION); return EXIT_SUCCESS; - case GOPT_VERBOSE: - global_options.verbose = true; - break; - case GOPT_QUIET: - global_options.quiet = true; - break; default: libinput_tool_usage(); return EXIT_FAILURE; } } - if (optind > argc) { + if (optind >= argc) { libinput_tool_usage(); return EXIT_FAILURE; } - command = argv[optind]; - - if (streq(command, "list-devices")) { - cmd = COMMAND_LIST_DEVICES; - } else if (streq(command, "debug-events")) { - cmd = COMMAND_DEBUG_EVENTS; - } else { - fprintf(stderr, "Invalid command '%s'\n", command); - return EXIT_FAILURE; - } + argv += optind; + argc -= optind; - return run_args_cmd(cmd, &global_options, argc - optind, &argv[optind]); + return exec_command(argc, argv); } diff --git a/tools/libinput-tool.h b/tools/libinput-tool.h index c451857..d7e6f7a 100644 --- a/tools/libinput-tool.h +++ b/tools/libinput-tool.h @@ -28,13 +28,6 @@ #include <stdbool.h> -struct global_options { - bool verbose; - bool quiet; -}; - void libinput_tool_usage(void); -int libinput_list_devices(struct global_options *opts, int argc, char **argv); -int libinput_debug_events(struct global_options *opts, int argc, char **argv); #endif diff --git a/tools/libinput.1 b/tools/libinput.1 index 0dd596e..03d85d6 100644 --- a/tools/libinput.1 +++ b/tools/libinput.1 @@ -2,11 +2,11 @@ .SH NAME libinput \- tool to interface with libinput .SH SYNOPSIS -.B libinput [GLOBAL OPTIONS] [COMMAND] [ARGS] +.B libinput [--help] [--version] <command> [<args>] .SH DESCRIPTION .PP The -.I libinput +.B "libinput" tool creates a libinput context on the default seat "seat0" and interacts with that libinput context. .PP @@ -18,116 +18,33 @@ of that created by the X.Org libinput driver, the Wayland compositor or any other process that utilizes libinput (henceforth called "the caller"). Configuration options set in this context do not affect any other libinput contexts. -.SH GLOBAL OPTIONS -These options are independent of any -.B COMMAND +.PP +Note that a device may be recognized by this tool but not handled by the +X.Org libinput driver or the Wayland compositor. +.SH OPTIONS .TP 8 .B --help Print help and exit .TP 8 .B --version Print the version and exit -.TP 8 -.B --verbose -Enable verbose mode. In verbose mode, libinput will print a number of -debug messages to stdout. The exact behavior of verbose mode depends on the -.B COMMAND. -.TP 8 -.B --quiet -Enable quiet mode. In quiet mode, most messages normally printed to stdout -will be omitted. The exact behavior of quiet mode depends on the -.B COMMAND. .SH COMMANDS All commands support a .B --help argument that prints command-specific usage -information (e.g. -.B libinput debug-events --help) +information, e.g. +.B "libinput debug-events --help". .TP 8 -.B debug-events [ARGS] -Print all events as seen by libinput. See section -.B debug-events +.B libinput-debug-events(1) +Print all events as seen by libinput. .TP 8 -.B list-devices -List all devices recognized by libinput. See section -.B list-devices - -.SS debug-events [...] -Print all events from these devices. -.PP -This is a debugging tool only, its output may change at any time. Do not -rely on the output. -.PP -.B --device /path/to/device -.IP -Use a path backend for the device for the given path. This option is -mutually exclusive with the -.B --udev -option. -.PP -.B --grab -.IP -Exclusively grab all devices. This will prevent events from being sent to -any other caller. It is recommended this option is only used together with -the -.B --device -option, otherwise a user may not be able to terminate this tool. -.PP -.B --udev <name> -.IP -Use a udev backend for this context with the given seat name. This option is -mutually exclusive with the -.B --device -option. -.PP -.B --show-keycodes -.IP -Print all keycodes as-is. Without this argument, most key events shown by -this tool are obfuscated to avoid passwords and other sensitive -information showing up in the output. -.PP -.B --enable-<feature> -or -.B --disable-<feature> -.IP -Enable or disable the given feature. For a full list of features, see the -.B --help -output. Requests to enable or disable a feature on a device that does -not provide that feature, or where that feature is already enabled or -disabled will be silently ignored. -.PP -.B --set-<feature>=<value> -.IP -Set the given feature to the given value. For a full list of features, see -the -.B --help -output. Requests to set a feature on a device that does not provide that -feature, or where that feature is already set to that value, or where the -value is not available on that device will be silently ignored - -.SS list-devices -List all devices recognized by libinput. Each device shows available -configurations the respective -.B default -configuration setting. -.PP -For configuration options that allow multiple different settings (e.g. -scrolling), all available settings are listed. The default setting is -prefixed by an asterisk (*). -.PP -Note that some specific feature may still be available on a device even when -no configuration is exposed, a lack of a configuration option does not -necessarily mean that this feature does not work. -.PP -Note that this command only lists -.B default -configuration settings, settings modified in other contextx by the caller -are not reflected in this tool. -.SH NOTES -.PP -A device may be recognized by this libinput context but not handled by the -X.Org libinput driver or the Wayland compositor. +.B libinput-list-devices(1) +List all devices recognized by libinput. +.SH LIBINPUT +Part of the +.B libinput(1) +suite .PP .SH SEE ALSO .PP diff --git a/tools/shared.c b/tools/shared.c index f26f81b..bdbf820 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -95,12 +95,7 @@ log_handler(struct libinput *li, void tools_usage(void) { -#if TOOLS_BUILD_STANDALONE - printf("Usage: %s [options] [--udev [<seat>]|--device /dev/input/event0]\n", - program_invocation_short_name); -#else printf("Usage: libinput debug-events [options] [--udev [<seat>]|--device /dev/input/event0]\n"); -#endif printf("--udev <seat>.... Use udev device discovery (default).\n" " Specifying a seat ID is optional.\n" "--device /path/to/device .... open the given device only\n" @@ -134,11 +129,8 @@ tools_usage(void) "Other options:\n" "--grab .......... Exclusively grab all openend devices\n" "--help .......... Print this help.\n" - ); -#if TOOLS_BUILD_STANDALONE - printf("--verbose ....... Print debugging output.\n" + "--verbose ....... Print debugging output.\n" "--quiet ......... Only print libinput messages, useful in combination with --verbose.\n"); -#endif } void @@ -180,10 +172,8 @@ tools_parse_args(int argc, char **argv, struct tools_context *context) { "udev", no_argument, 0, OPT_UDEV }, { "grab", no_argument, 0, OPT_GRAB }, { "help", no_argument, 0, OPT_HELP }, -#if TOOLS_BUILD_STANDALONE { "verbose", no_argument, 0, OPT_VERBOSE }, { "quiet", no_argument, 0, OPT_QUIET }, -#endif { "enable-tap", no_argument, 0, OPT_TAP_ENABLE }, { "disable-tap", no_argument, 0, OPT_TAP_DISABLE }, { "enable-drag", no_argument, 0, OPT_DRAG_ENABLE }, @@ -234,7 +224,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context) options->grab = 1; break; case OPT_VERBOSE: - options->global_options.verbose = 1; + options->verbose = 1; break; case OPT_TAP_ENABLE: options->tapping = 1; @@ -373,7 +363,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context) options->show_keycodes = true; break; case OPT_QUIET: - options->global_options.quiet = true; + options->quiet = true; break; default: tools_usage(); @@ -495,12 +485,12 @@ tools_open_backend(struct tools_context *context) li = open_udev(&interface, context, options->seat, - options->global_options.verbose); + options->verbose); } else if (options->backend == BACKEND_DEVICE) { li = open_device(&interface, context, options->device, - options->global_options.verbose); + options->verbose); } else { abort(); } diff --git a/tools/shared.h b/tools/shared.h index 03838e1..f3a10db 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -36,7 +36,8 @@ enum tools_backend { }; struct tools_options { - struct global_options global_options; + bool verbose; + bool quiet; enum tools_backend backend; const char *device; /* if backend is BACKEND_DEVICE */ const char *seat; /* if backend is BACKEND_UDEV */ |