sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 9d1c182ee12279f8b5fcd610ce458987bdf47d2e
parent f6fd0f0a12ef454333952fc817f435070bbfd865
Author: Anton Yabchinskiy <arn@bestmx.net>
Date:   Sun,  1 Oct 2023 23:19:28 +0300

Added setxkbgroup patch for dwm-6.4

Diffstat:
Adwm.suckless.org/patches/setxkbgroup/dwm-setxkbgroup-6.4.diff | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/setxkbgroup/index.md | 35+++++++++++++++++++++++++++++++++++
2 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/setxkbgroup/dwm-setxkbgroup-6.4.diff b/dwm.suckless.org/patches/setxkbgroup/dwm-setxkbgroup-6.4.diff @@ -0,0 +1,54 @@ +From cbaa365a336355712e3c63a550f903b2cd46ab58 Mon Sep 17 00:00:00 2001 +From: Anton Yabchinskiy <arn@bestmx.net> +Date: Sun, 1 Oct 2023 22:42:59 +0300 +Subject: [PATCH] Add setxkbgroup() function to be used in keys[] + +--- + dwm.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/dwm.c b/dwm.c +index e5efb6a2..4a6632f3 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -36,6 +36,7 @@ + #include <X11/Xlib.h> + #include <X11/Xproto.h> + #include <X11/Xutil.h> ++#include <X11/XKBlib.h> + #ifdef XINERAMA + #include <X11/extensions/Xinerama.h> + #endif /* XINERAMA */ +@@ -234,6 +235,7 @@ static int xerror(Display *dpy, XErrorEvent *ee); + static int xerrordummy(Display *dpy, XErrorEvent *ee); + static int xerrorstart(Display *dpy, XErrorEvent *ee); + static void zoom(const Arg *arg); ++static void setxkbgroup(const Arg *arg); + + /* variables */ + static const char broken[] = "broken"; +@@ -2122,6 +2124,21 @@ zoom(const Arg *arg) + pop(c); + } + ++void ++setxkbgroup(const Arg *arg) { ++ static int hasxkb = -1; ++ if (hasxkb < 0) { ++ int major = XkbMajorVersion; ++ int minor = XkbMinorVersion; ++ hasxkb = XkbQueryExtension(dpy, NULL, NULL, NULL, &major, &minor); ++ } ++ if (hasxkb > 0) { ++ if (arg != NULL && arg->ui < 4) { ++ XkbLockGroup(dpy, XkbUseCoreKbd, arg->ui); ++ } ++ } ++} ++ + int + main(int argc, char *argv[]) + { +-- +2.39.2 + diff --git a/dwm.suckless.org/patches/setxkbgroup/index.md b/dwm.suckless.org/patches/setxkbgroup/index.md @@ -0,0 +1,35 @@ +setxkbgroup +=========== + +Description +----------- +The patch adds a new `setxkbgroup` function to be used inside +`keys[]`. It allows idempotent keyboard layout switching from dwm +itself. + +Suppose you've configured keyboard layouts in X server like this: + +`setxkbmap -option 'grp:rctrl_toggle' -layout 'us,ru,epo,gr(bare)'` + +And then have defined a few key bindings in the `keys[]` array in dwm +`config.h` like this: + + ... + { MODKEY, XK_u, setxkbgroup, {.ui = 0 } }, + { MODKEY, XK_r, setxkbgroup, {.ui = 1 } }, + { MODKEY, XK_e, setxkbgroup, {.ui = 2 } }, + { MODKEY, XK_g, setxkbgroup, {.ui = 3 } }, + ... + +Configured like this, `MOD+r` in dwm immediately activates Russian +layout, `MOD+g` switches to Greek and `MOD+u` gets the US layout. You +don't need to track how many times to press Right Ctrl (or whatever) +key to use a desired layout. + +Download +-------- +* [dwm-setxkbgroup-6.4.diff](dwm-setxkbgroup-6.4.diff) + +Author +------ +* Anton Yabchinskiy <arn+53a4f52@bestmx.net>