From eb921aa2931859f55b11f3cc42a7fadd147a58d9 Mon Sep 17 00:00:00 2001 From: anastasisg Date: Wed, 12 Feb 2025 00:44:47 +0200 Subject: keysym to ignore layout --- xlnch.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'xlnch.c') diff --git a/xlnch.c b/xlnch.c index a5ffd62..f39f606 100644 --- a/xlnch.c +++ b/xlnch.c @@ -302,11 +302,16 @@ int run() return 0; } - XLookupString(&event.xkey, text, 255, &keysym, 0); - flag = 0; - for (unsigned int i = 0; i < idx; i++) { - if (lnch[i].key == text[0]) { + char tmp[128] = ""; + // get configured key + tmp[0] = lnch[i].key; + tmp[1] = '\0'; + // convert to keysym, and then to keycode Keycodes are consistent + // across layouts but may vary between different keyboard models. + // For example, the keycode for the "A" key might differ between + // a US QWERTY keyboard and a French AZERTY keyboard. + if (XKeysymToKeycode(display, XStringToKeysym(tmp)) == event.xkey.keycode) { rc = run_cmd(lnch[i].cmd); flag = 1; if (lnch[i].exits) { -- cgit v1.2.3