diff --git a/thd.c b/thd.c index a703231..d42a692 100644 --- a/thd.c +++ b/thd.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -214,6 +215,7 @@ static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"uinput", required_argument, 0, '<'}, {"listevents", no_argument, 0, 'l'}, + {"deviceglob", required_argument, 0, 'g'}, {0,0,0,0} /* end of list */ }; @@ -231,6 +233,7 @@ void show_help(void) { printf( " --ignore Ignore key events with name \n" ); printf( " --normalize Normalize relative movement events\n" ); printf( " --user Drop privileges to after opening devices\n" ); + printf( " --deviceglob

Open device files matching pattern

\n" ); } static void list_event_table(int type, int max) { @@ -289,8 +292,8 @@ static void handle_signal(int sig) { } } -int start_readers(int argc, char *argv[], int start) { - if (argc-start < 1 && cmd_file == NULL) { +int start_readers(int argc, char *argv[], int start, char *dev_glob) { + if (argc-start < 1 && cmd_file == NULL && dev_glob == NULL) { fprintf(stderr, "No input device files or command pipe specified.\n"); return 1; } @@ -315,6 +318,16 @@ int start_readers(int argc, char *argv[], int start) { char *tag_dev = NULL; add_device( dev, -1, grab_dev, tag_dev ); } + /* check device glob */ + if (dev_glob) { + glob_t globbuf; + glob(dev_glob, GLOB_NOSORT, NULL, &globbuf); + for (i=0; i [B<--help>] [B<--user> I] [B<--listevents>] [B<--dump>] [B<--socket> I] [B<--triggers> I] [B<--daemon>] [B<--pidfile> I] [B<--uinput> I][B<--ignore> I] [I] +B [B<--help>] [B<--user> I] [B<--listevents>] [B<--dump>] [B<--socket> I] [B<--triggers> I] [B<--daemon>] [B<--pidfile> I] [B<--uinput> I][B<--ignore> I] [B<--deviceglob> I] [I] =head1 DESCRIPTION @@ -65,6 +65,10 @@ Normalize REL and ABS events. If this option is enabled, the values of axis move Change to user id I after opening files. This usually prevents thd from opening additional input devices, unless they are opened by the th-cmd program and their file descriptor are passed to the daemon. +=item B<--deviceglob> I + +Open device files matching the glob I. + =back Additional command line arguments are considered filenames of input devices.