tools: switch the libinput tool to be an exec-ing tool
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 25 May 2017 00:12:26 +0000 (10:12 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 2 Jun 2017 02:21:35 +0000 (12:21 +1000)
Chaining args together inside a single binary would be nice, but it gets nasty
quickly (as I found out adding 3, 4 extra commands). Switch over to using a
git-style exec-ing command where libinput merely changes argv[0] and then
executes whatever it assembled. And those binaries can hide in libexec so they
don't clutter up the global namespace.

This also makes it a lot easier to write man pages, adopt the same style as
git uses.

Compatibilty wrapper scripts are provided for libinput-list-devices and
libinput-debug events. These warn the user about the changed command, then
exec the new one. Expect these wrappers to be removed at some point in the
future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
15 files changed:
meson.build
tools/.gitignore
tools/Makefile.am
tools/install-compat-scripts.sh [new file with mode: 0755]
tools/libinput-debug-events.1
tools/libinput-debug-events.c
tools/libinput-debug-events.compat [new file with mode: 0755]
tools/libinput-list-devices.1
tools/libinput-list-devices.c [changed mode: 0644->0755]
tools/libinput-list-devices.compat [new file with mode: 0755]
tools/libinput-tool.c
tools/libinput-tool.h
tools/libinput.1
tools/shared.c
tools/shared.h

index 0a3028e05463fa0328cc9c32825321362bcae4d1..0bd96a941d8090803d5a228998a7c91d019220b0 100644 (file)
@@ -340,6 +340,8 @@ if doxygen.found()
 endif
 
 ############ tools ############
+libinput_tool_path = join_paths(get_option('prefix'), get_option('libexecdir'), 'libinput')
+config_h.set_quoted('LIBINPUT_TOOL_PATH', libinput_tool_path)
 tools_shared_sources = [ 'tools/shared.c',
                         'tools/shared.h' ]
 libinput_debug_events_sources = [ 'tools/libinput-debug-events.c' ] + tools_shared_sources
@@ -347,7 +349,7 @@ executable('libinput-debug-events',
           libinput_debug_events_sources,
           dependencies : dep_libinput,
           include_directories : include_directories('src'),
-          c_args : [ '-DTOOLS_BUILD_STANDALONE=1' ],
+          install_dir : libinput_tool_path,
           install : true
           )
 
@@ -356,11 +358,11 @@ executable('libinput-list-devices',
           libinput_list_devices_sources,
           dependencies : [ dep_libinput ],
           include_directories : include_directories('src'),
-          c_args : [ '-DTOOLS_BUILD_STANDALONE=1' ],
+          install_dir : libinput_tool_path,
           install : true,
           )
 
-libinput_sources = [ 'tools/libinput-tool.c' ] + libinput_list_devices_sources + libinput_debug_events_sources
+libinput_sources = [ 'tools/libinput-tool.c' ]
 
 executable('libinput',
           libinput_sources,
@@ -402,6 +404,7 @@ endif
 install_man('tools/libinput-list-devices.1',
            'tools/libinput-debug-events.1')
 
+meson.add_install_script('tools/install-compat-scripts.sh')
 
 ############ tests ############
 
index 2e4c93d324dad5ff34220e0e1b53d52e1959a4ef..9bdb48d14ac16d761317952f481877003ec8e1c9 100644 (file)
@@ -1,4 +1,2 @@
 event-gui
 ptraccel-debug
-libinput-list-devices
-libinput-debug-events
index 68d1fd452d2e05335d4aabbd418584ff2936b839..0702dc6b774c4cd6b182845990320d7d7f894c78 100644 (file)
@@ -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 (executable)
index 0000000..0d8b3ad
--- /dev/null
@@ -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"
index dfc9a458cf7b4d3bd2658e42a890c32029aa4230..b0dbc3976e2190646953e146fc1cdf6262c5df5c 100644 (file)
@@ -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
index f64708d0ca756da8b64c2fde582c5f6d53961f60..cf29dab58a31dcfdc5fc1748c5530491532df8ac 100644 (file)
@@ -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 (executable)
index 0000000..dc11af7
--- /dev/null
@@ -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 $@
index 99a66b52431ef9bbe8bdcb56ac801e423669d4c1..555c0fd1db3ab2edd093fcb72e6c76e03cfde96a 100644 (file)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index a0154d3..9d6c70b
@@ -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 (executable)
index 0000000..3fe3baa
--- /dev/null
@@ -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 $@
index 1485419db6953ad64504ac147ea5e75944a1d393..32bb0e5cc4a39a52d10c88f35f65e6f8b5a651cd 100644 (file)
@@ -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);
 }
index c4518579fbcee4ccecb59212fa49824e1d8f257a..d7e6f7a59054b4ef819b9928f14d1d68980d3e4f 100644 (file)
 
 #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
index 0dd596e68f6ed614608cea521fd7fbdc778bce71..03d85d6c8fda21d63db8e27de4c138933f99c250 100644 (file)
@@ -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)
+informatione.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
index f26f81b006b9025543d37c0de2e26401caf96075..bdbf82078180a5c2eab597690ad2a692267793c8 100644 (file)
@@ -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();
        }
index 03838e145e3be0863b5ffd669ee4e3a76979ccf7..f3a10db9d9b309de2e938d575be0ac7041bc0fd7 100644 (file)
@@ -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 */