From a4fb620aa328a2c9adfdafdac95500bbea04b434 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 4 Mar 2024 21:57:22 -0800 Subject: add version and -v opt --- xkbdlock.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xkbdlock.c b/xkbdlock.c index d11a8cd..627a1e6 100644 --- a/xkbdlock.c +++ b/xkbdlock.c @@ -8,6 +8,8 @@ #include #include +#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"); -- cgit v1.2.3-70-g09d2