diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-03-04 21:57:22 -0800 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-03-04 21:57:22 -0800 |
commit | a4fb620aa328a2c9adfdafdac95500bbea04b434 (patch) | |
tree | cc9a0088f148bbe3c6cc68a19420eea0d35d28ab | |
parent | 51ffd3e08c58a691d6352bbf08ce0f4933d93648 (diff) | |
download | xkbdlock-master.tar.gz xkbdlock-master.tar.xz |
-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"); |