summaryrefslogtreecommitdiff
path: root/xkbdlock.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-04 21:57:22 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-04 21:57:22 -0800
commita4fb620aa328a2c9adfdafdac95500bbea04b434 (patch)
treecc9a0088f148bbe3c6cc68a19420eea0d35d28ab /xkbdlock.c
parent51ffd3e08c58a691d6352bbf08ce0f4933d93648 (diff)
downloadxkbdlock-8fd42152a1cdb93a878208c8a33137b44eb0236a.tar.gz
xkbdlock-8fd42152a1cdb93a878208c8a33137b44eb0236a.tar.xz
add version and -v optHEADv0.1master
Diffstat (limited to 'xkbdlock.c')
-rw-r--r--xkbdlock.c11
1 files 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 <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");