diff options
-rw-r--r-- | xkbdlock.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -8,6 +8,8 @@ #include <X11/Xlib.h> #include <X11/keysym.h> +#define VERSION "0.1" + struct named_mask { const char *name; unsigned int mask; @@ -69,7 +71,7 @@ static bool grab_kbd(Display *d, int screen) usleep(100000); } - return (res == GrabSuccess); + return res == GrabSuccess; } static void wait_for_release(Display *d, KeySym key, unsigned int mask) @@ -78,7 +80,7 @@ static void wait_for_release(Display *d, KeySym key, unsigned int mask) while (!XNextEvent(d, &ev)) { if (ev.type == KeyPress && XLookupKeysym(&ev.xkey, 0) == key && - (mask & ev.xkey.state) == mask) + (ev.xkey.state & mask) == mask) break; } } @@ -89,7 +91,10 @@ int main(int argc, char **argv) KeySym key = NoSymbol, arg_key; for (int i = 1; i < argc; ++i) { - if ((arg_mask = name_to_mask(argv[i]))) { + if (!strcmp(argv[i], "-v")) { + puts("xkbdlock-" VERSION); + return 0; + } else if ((arg_mask = name_to_mask(argv[i]))) { mask = mask | arg_mask; } else if (key != NoSymbol) { die("more than one non-modifier key provided"); |