commit dc7474a
chld
·
2026-07-14 15:34:28 +0000 UTC
parent 668dc11
text building
M
Makefile
+2,
-2
1@@ -7,8 +7,8 @@ PKG_CONFIG = pkg-config
2
3 CFLAGS += -std=c99 -Wall -Wextra -Oz -Wno-unused-parameter
4
5-PKG_CFLAGS != ${PKG_CONFIG} --cflags x11
6-PKG_LIBS != ${PKG_CONFIG} --libs x11
7+PKG_CFLAGS != ${PKG_CONFIG} --cflags x11 xkbcommon
8+PKG_LIBS != ${PKG_CONFIG} --libs x11 xkbcommon
9
10 CPPFLAGS += ${WLD_CFLAGS} -I. -I/usr/local/include -I${PREFIX}/include
11 SRCS = ${SRC}.c
M
xtr
+0,
-0
M
xtr.c
+17,
-1
1@@ -1,5 +1,6 @@
2 #include <X11/Xlib.h>
3 #include <X11/keysym.h>
4+#include <xkbcommon/xkbcommon.h>
5
6 #include <stdbool.h>
7 #include <stdio.h>
8@@ -98,6 +99,12 @@ int main(int ac, char **av) {
9 font = XLoadQueryFont(d, "fixed");
10 XSetFont(d, gc, font->fid);
11
12+ char cmd[1024];
13+ size_t idx = 0;
14+ for (int c = 0; c < 1023; c++) {
15+ cmd[c] = 0;
16+ }
17+
18 while (1) {
19 XEvent ev;
20 XNextEvent(d, &ev);
21@@ -122,8 +129,17 @@ int main(int ac, char **av) {
22 }
23 case KeyPress: {
24 KeySym k = XLookupKeysym(&ev.xkey, 0);
25- if (k == XK_Escape)
26+ if (k == XK_Escape) {
27+ puts(cmd);
28 goto q;
29+ }
30+
31+ char buf[32];
32+ int l = xkb_keysym_to_utf8(k, buf, sizeof buf);
33+ if (l > 0) {
34+ // printf("%s\n", buf);
35+ cmd[idx++] = buf[0];
36+ }
37
38 break;
39 }