[download]
local/bin/xkbstate
1
2
3
4
5
6
7 int main(int argc, char *argv[]){
8 Display *dpy;
9 int last = -1;
10 XkbStateRec state;
11
12 if (!(dpy = XOpenDisplay(NULL)))
13 return 1;
14
15 while (True){
16 usleep(100000);
17 XkbGetState(dpy, XkbUseCoreKbd, &state);
18
19 if (state.group == last)
20 continue;
21
22 last = state.group;
23
24 if (argc > last + 1)
25 printf("%s\n", argv[last + 1]);
26 else
27 printf("%d\n", last);
28
29 fflush(stdout);
30 }
31
32 XCloseDisplay(dpy);
33 }
34
35
|