Adding keymodes patch

This commit is contained in:
bakkeby 2020-05-31 15:14:29 +02:00
parent e7ea06a0c2
commit af96d4c358
6 changed files with 62 additions and 0 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### Changelog:
2020-05-31 - Added the keymodes patch
2020-05-29 - Added the color emoji 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) 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/) - [ispermanent](https://dwm.suckless.org/patches/ispermanent/)
- adds rule option for clients to avoid accidental termination by killclient for sticky windows - 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/) - [leftlayout](http://dwm.suckless.org/patches/leftlayout/)
- moves the layout symbol in the status bar to the left hand side - moves the layout symbol in the status bar to the left hand side

View File

@ -702,6 +702,9 @@ static const unsigned scratchpad_mask = 1u << sizeof tags / sizeof * tags;
static Key keys[] = { static Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
#if KEYMODES_PATCH
{ MODKEY, XK_Escape, setkeymode, {.ui = COMMANDMODE} },
#endif // KEYMODES_PATCH
{ MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_b, togglebar, {0} },
@ -991,6 +994,32 @@ static Key keys[] = {
TAGKEYS( XK_9, 8) 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 */ /* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = { static Button buttons[] = {

16
dwm.c
View File

@ -364,9 +364,17 @@ static int getrootptr(int *x, int *y);
static long getstate(Window w); static long getstate(Window w);
static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, int focused); static void grabbuttons(Client *c, int focused);
#if KEYMODES_PATCH
static void grabdefkeys(void);
#else
static void grabkeys(void); static void grabkeys(void);
#endif // KEYMODES_PATCH
static void incnmaster(const Arg *arg); static void incnmaster(const Arg *arg);
#if KEYMODES_PATCH
static void keydefpress(XEvent *e);
#else
static void keypress(XEvent *e); static void keypress(XEvent *e);
#endif // KEYMODES_PATCH
static void killclient(const Arg *arg); static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa); static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e); static void mappingnotify(XEvent *e);
@ -1987,7 +1995,11 @@ grabbuttons(Client *c, int focused)
} }
void void
#if KEYMODES_PATCH
grabdefkeys(void)
#else
grabkeys(void) grabkeys(void)
#endif // KEYMODES_PATCH
{ {
updatenumlockmask(); updatenumlockmask();
{ {
@ -2028,7 +2040,11 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
#endif /* XINERAMA */ #endif /* XINERAMA */
void void
#if KEYMODES_PATCH
keydefpress(XEvent *e)
#else
keypress(XEvent *e) keypress(XEvent *e)
#endif // KEYMODES_PATCH
{ {
unsigned int i; unsigned int i;
KeySym keysym; KeySym keysym;

View File

@ -61,6 +61,9 @@
#if INPLACEROTATE_PATCH #if INPLACEROTATE_PATCH
#include "inplacerotate.c" #include "inplacerotate.c"
#endif #endif
#if KEYMODES_PATCH
#include "keymodes.c"
#endif
#if KILLUNSEL_PATCH #if KILLUNSEL_PATCH
#include "killunsel.c" #include "killunsel.c"
#endif #endif

View File

@ -64,6 +64,9 @@
#if INPLACEROTATE_PATCH #if INPLACEROTATE_PATCH
#include "inplacerotate.h" #include "inplacerotate.h"
#endif #endif
#if KEYMODES_PATCH
#include "keymodes.h"
#endif
#if KILLUNSEL_PATCH #if KILLUNSEL_PATCH
#include "killunsel.h" #include "killunsel.h"
#endif #endif

View File

@ -294,6 +294,12 @@
*/ */
#define IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH 0 #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. /* This patch adds a keybinding to kills all visible clients that are not selected.
* https://dwm.suckless.org/patches/killunsel/ * https://dwm.suckless.org/patches/killunsel/
*/ */