diff --git a/xbanish.1 b/xbanish.1 index 3d0f29b..acf37f7 100644 --- a/xbanish.1 +++ b/xbanish.1 @@ -9,6 +9,7 @@ .Op Fl a .Op Fl d .Op Fl i Ar modifier +.Op Fl k Ar keyboard_prefix .Op Fl m Oo Ar w Oc Ns Ar nw|ne|sw|se|\(+-x\(+-y .Op Fl t Ar seconds .Op Fl s @@ -49,6 +50,8 @@ Modifiers are: .Ic mod5 (ISO Level 3 Shift), and .Ic all +.It Fl k Ar keyboard_prefix +When used, will only attach to the keyboards device that match the start of the argument. Useful when running kmonad or xremap. .It Fl m Oo Ar w Oc Ns Ar nw|ne|sw|se|\(+-x\(+-y When hiding the mouse cursor, move it to this corner of the screen or current window, then move it back when showing the cursor. diff --git a/xbanish.c b/xbanish.c index e15f620..0611efe 100644 --- a/xbanish.c +++ b/xbanish.c @@ -56,6 +56,8 @@ static unsigned char ignored; static XSyncCounter idler_counter = 0; static XSyncAlarm idle_alarm = None; +static char *master_keyboard_device; + static int debug = 0; #define DPRINTF(x) { if (debug) { printf x; } }; @@ -94,7 +96,7 @@ main(int argc, char *argv[]) {"all", -1}, }; - while ((ch = getopt(argc, argv, "adi:m:t:s")) != -1) + while ((ch = getopt(argc, argv, "adi:k:m:t:s")) != -1) switch (ch) { case 'a': always_hide = 1; @@ -108,6 +110,10 @@ main(int argc, char *argv[]) if (strcasecmp(optarg, mods[i].name) == 0) ignored |= mods[i].mask; + break; + case 'k': + // choose which keyboard device to listen only (in case of xremap or Kmonad being used) + master_keyboard_device = optarg; break; case 'm': if (strcmp(optarg, "nw") == 0) @@ -463,6 +469,10 @@ snoop_xinput(Window win) ici++, j++) { switch (ici->input_class) { case KeyClass: + if (master_keyboard_device && + strncmp(master_keyboard_device, devinfo[i].name, strlen(master_keyboard_device)) != 0) + continue; + DPRINTF(("attaching to keyboard device %s " "(use %d)\n", devinfo[i].name, devinfo[i].use)); @@ -587,7 +597,7 @@ set_alarm(XSyncAlarm *alarm, XSyncTestType test) void usage(char *progname) { - fprintf(stderr, "usage: %s [-a] [-d] [-i mod] [-m [w]nw|ne|sw|se|+/-xy] " + fprintf(stderr, "usage: %s [-a] [-d] [-i mod] [-k master_keyboard] [-m [w]nw|ne|sw|se|+/-xy] " "[-t seconds] [-s]\n", progname); exit(1); }