summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--config.def.h29
-rw-r--r--dwm.c16
-rw-r--r--patch/include.c3
-rw-r--r--patch/include.h3
-rw-r--r--patches.def.h6
6 files changed, 62 insertions, 0 deletions
diff --git a/README.md b/README.md
index cdbbaf2..aa6bc4d 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
+2020-05-31 - Added the keymodes patch
+
2020-05-29 - Added the color emoji patch
2020-05-26 - Added the status2d patch (with alpha, systray, statuspadding and dwmblocks compatibility, no statuscolors or extrabar compatibility)
@@ -259,6 +261,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [ispermanent](https://dwm.suckless.org/patches/ispermanent/)
- adds rule option for clients to avoid accidental termination by killclient for sticky windows
+ - [keymodes](https://dwm.suckless.org/patches/keymodes/)
+ - this patch adds key modes (like in vim or emacs) where chains of keyboard shortcuts can be performed
+
- [leftlayout](http://dwm.suckless.org/patches/leftlayout/)
- moves the layout symbol in the status bar to the left hand side
diff --git a/config.def.h b/config.def.h
index 2483f20..394d9a2 100644
--- a/config.def.h
+++ b/config.def.h
@@ -702,6 +702,9 @@ static const unsigned scratchpad_mask = 1u << sizeof tags / sizeof * tags;
static Key keys[] = {
/* modifier key function argument */
+ #if KEYMODES_PATCH
+ { MODKEY, XK_Escape, setkeymode, {.ui = COMMANDMODE} },
+ #endif // KEYMODES_PATCH
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
@@ -991,6 +994,32 @@ static Key keys[] = {
TAGKEYS( XK_9, 8)
};
+#if KEYMODES_PATCH
+static Key cmdkeys[] = {
+ /* modifier keys function argument */
+ { 0, XK_Escape, clearcmd, {0} },
+ { ControlMask, XK_c, clearcmd, {0} },
+ { 0, XK_i, setkeymode, {.ui = INSERTMODE} },
+};
+
+static Command commands[] = {
+ /* modifier (4 keys) keysyms (4 keys) function argument */
+ { {ControlMask, ShiftMask, 0, 0}, {XK_w, XK_h, 0, 0}, setlayout, {.v = &layouts[0]} },
+ { {ControlMask, 0, 0, 0}, {XK_w, XK_o, 0, 0}, setlayout, {.v = &layouts[2]} },
+ { {ControlMask, ShiftMask, 0, 0}, {XK_w, XK_o, 0, 0}, onlyclient, {0} },
+ { {ControlMask, 0, 0, 0}, {XK_w, XK_v, 0, 0}, setlayout, {.v = &layouts[0]} },
+ { {ControlMask, 0, 0, 0}, {XK_w, XK_less, 0, 0}, setmfact, {.f = -0.05} },
+ { {ControlMask, ShiftMask, 0, 0}, {XK_w, XK_less, 0, 0}, setmfact, {.f = +0.05} },
+ { {ControlMask, ShiftMask, 0, 0}, {XK_w, XK_0, 0, 0}, setmfact, {.f = +1.50} },
+ { {ShiftMask, 0, 0, 0}, {XK_period, XK_e, 0, 0}, spawn, {.v = dmenucmd} },
+ { {ShiftMask, 0, 0, 0}, {XK_period, XK_o, 0, 0}, spawn, {.v = dmenucmd} },
+ { {ShiftMask, 0, 0, 0}, {XK_period, XK_q, XK_Return, 0}, quit, {0} },
+ { {ShiftMask, 0, 0, 0}, {XK_period, XK_b, XK_d, XK_Return}, killclient, {0} },
+ { {ShiftMask, 0, 0, 0}, {XK_period, XK_b, XK_n, XK_Return}, focusstack, {.i = +1} },
+ { {ShiftMask, 0, ShiftMask, 0}, {XK_period, XK_b, XK_n, XK_Return}, focusstack, {.i = -1} },
+};
+#endif // KEYMODES_PATCH
+
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
diff --git a/dwm.c b/dwm.c
index ed6b9e1..9d79b5b 100644
--- a/dwm.c
+++ b/dwm.c
@@ -364,9 +364,17 @@ static int getrootptr(int *x, int *y);
static long getstate(Window w);
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, int focused);
+#if KEYMODES_PATCH
+static void grabdefkeys(void);
+#else
static void grabkeys(void);
+#endif // KEYMODES_PATCH
static void incnmaster(const Arg *arg);
+#if KEYMODES_PATCH
+static void keydefpress(XEvent *e);
+#else
static void keypress(XEvent *e);
+#endif // KEYMODES_PATCH
static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
@@ -1987,7 +1995,11 @@ grabbuttons(Client *c, int focused)
}
void
+#if KEYMODES_PATCH
+grabdefkeys(void)
+#else
grabkeys(void)
+#endif // KEYMODES_PATCH
{
updatenumlockmask();
{
@@ -2028,7 +2040,11 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
#endif /* XINERAMA */
void
+#if KEYMODES_PATCH
+keydefpress(XEvent *e)
+#else
keypress(XEvent *e)
+#endif // KEYMODES_PATCH
{
unsigned int i;
KeySym keysym;
diff --git a/patch/include.c b/patch/include.c
index 5113dc6..49785da 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -61,6 +61,9 @@
#if INPLACEROTATE_PATCH
#include "inplacerotate.c"
#endif
+#if KEYMODES_PATCH
+#include "keymodes.c"
+#endif
#if KILLUNSEL_PATCH
#include "killunsel.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index bb0197d..d26d740 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -64,6 +64,9 @@
#if INPLACEROTATE_PATCH
#include "inplacerotate.h"
#endif
+#if KEYMODES_PATCH
+#include "keymodes.h"
+#endif
#if KILLUNSEL_PATCH
#include "killunsel.h"
#endif
diff --git a/patches.def.h b/patches.def.h
index a897412..967749a 100644
--- a/patches.def.h
+++ b/patches.def.h
@@ -294,6 +294,12 @@
*/
#define IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH 0
+/* This patch adds key modes (like in vim or emacs) where chains of keyboard shortcuts
+ * can be performed.
+ * https://dwm.suckless.org/patches/keymodes/
+ */
+#define KEYMODES_PATCH 0
+
/* This patch adds a keybinding to kills all visible clients that are not selected.
* https://dwm.suckless.org/patches/killunsel/
*/