dwm-setxkbgroup-6.4.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-setxkbgroup-6.4.diff (1326B)
---
1 From cbaa365a336355712e3c63a550f903b2cd46ab58 Mon Sep 17 00:00:00 2001
2 From: Anton Yabchinskiy <arn@bestmx.net>
3 Date: Sun, 1 Oct 2023 22:42:59 +0300
4 Subject: [PATCH] Add setxkbgroup() function to be used in keys[]
5
6 ---
7 dwm.c | 17 +++++++++++++++++
8 1 file changed, 17 insertions(+)
9
10 diff --git a/dwm.c b/dwm.c
11 index e5efb6a2..4a6632f3 100644
12 --- a/dwm.c
13 +++ b/dwm.c
14 @@ -36,6 +36,7 @@
15 #include <X11/Xlib.h>
16 #include <X11/Xproto.h>
17 #include <X11/Xutil.h>
18 +#include <X11/XKBlib.h>
19 #ifdef XINERAMA
20 #include <X11/extensions/Xinerama.h>
21 #endif /* XINERAMA */
22 @@ -234,6 +235,7 @@ static int xerror(Display *dpy, XErrorEvent *ee);
23 static int xerrordummy(Display *dpy, XErrorEvent *ee);
24 static int xerrorstart(Display *dpy, XErrorEvent *ee);
25 static void zoom(const Arg *arg);
26 +static void setxkbgroup(const Arg *arg);
27
28 /* variables */
29 static const char broken[] = "broken";
30 @@ -2122,6 +2124,21 @@ zoom(const Arg *arg)
31 pop(c);
32 }
33
34 +void
35 +setxkbgroup(const Arg *arg) {
36 + static int hasxkb = -1;
37 + if (hasxkb < 0) {
38 + int major = XkbMajorVersion;
39 + int minor = XkbMinorVersion;
40 + hasxkb = XkbQueryExtension(dpy, NULL, NULL, NULL, &major, &minor);
41 + }
42 + if (hasxkb > 0) {
43 + if (arg != NULL && arg->ui < 4) {
44 + XkbLockGroup(dpy, XkbUseCoreKbd, arg->ui);
45 + }
46 + }
47 +}
48 +
49 int
50 main(int argc, char *argv[])
51 {
52 --
53 2.39.2
54