summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h19
-rw-r--r--dwl.c21
2 files changed, 32 insertions, 8 deletions
diff --git a/config.h b/config.h
index c5faa78..28f2265 100644
--- a/config.h
+++ b/config.h
@@ -84,13 +84,16 @@ static const MonitorRule monrules[] = {
};
/* keyboard */
-static const struct xkb_rule_names xkb_rules = {
- /* can specify fields: rules, model, layout, variant, options */
- /* example:
- .options = "ctrl:nocaps",
- */
- .options = NULL,
-};
+static const struct xkb_rule_names xkb_rules[] = {
+ {
+ .layout = "us"
+ /* .variant = "dvp", */
+ /* .options = "compose:102,numpad:shift3,kpdl:semi,keypad:atm,caps:super" */
+ },
+ {
+ .layout = "ca"
+ },
+ };
static const int repeat_rate = 50;
static const int repeat_delay = 300;
@@ -172,6 +175,8 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_plus, incgaps, {.i = +1 } },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_underscore, togglegaps, {0} },
{ MODKEY, XKB_KEY_equal, defaultgaps, {0} },
+ { WLR_MODIFIER_ALT, XKB_KEY_Return, incxkbrules, {0} },
+ // { WLR_MODIFIER_ALT, XKB_KEY_Return, incxkbrules, {.i = +1} },
// { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_H, incogaps, {.i = +1 } },
// { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_L, incogaps, {.i = -1 } },
// { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_h, incigaps, {.i = +1 } },
diff --git a/dwl.c b/dwl.c
index 912a6ef..3311ebd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -378,6 +378,7 @@ static void setup(void);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static int status_in(int fd, unsigned int mask, void *data);
+static void incxkbrules(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
@@ -450,6 +451,7 @@ static struct wl_listener lock_listener = {.notify = locksession};
static struct wlr_seat *seat;
static KeyboardGroup *kb_group;
+static unsigned int kblayout = 0;
static unsigned int cursor_mode;
static Client *grabc;
static Client initial_grabc;
@@ -1065,7 +1067,7 @@ createkeyboardgroup(void)
/* Prepare an XKB keymap and assign it to the keyboard group. */
context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
- if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules,
+ if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules[kblayout],
XKB_KEYMAP_COMPILE_NO_FLAGS)))
die("failed to compile keymap");
@@ -1091,6 +1093,23 @@ createkeyboardgroup(void)
}
void
+incxkbrules(const Arg *arg)
+{
+ struct xkb_context *context;
+ struct xkb_keymap *keymap;
+ kblayout = (kblayout+1)%LENGTH(xkb_rules);
+
+ context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules[kblayout],
+ XKB_KEYMAP_COMPILE_NO_FLAGS)))
+ die("failed to compile keymap");
+
+ wlr_keyboard_set_keymap(&kb_group->wlr_group->keyboard, keymap);
+ xkb_keymap_unref(keymap);
+ xkb_context_unref(context);
+}
+
+void
createlayersurface(struct wl_listener *listener, void *data)
{
struct wlr_layer_surface_v1 *layer_surface = data;