Compare commits
33
Commits
481f8e9d1f
...
b0cc093917
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0cc093917 | ||
|
|
2adf18bee6 | ||
|
|
9610f461c2 | ||
|
|
636dcaf763 | ||
|
|
239b74dcb2 | ||
|
|
b6ed779125 | ||
|
|
f8024479de | ||
|
|
8c32040130 | ||
|
|
31f21a2173 | ||
|
|
d94d37dc22 | ||
|
|
c166ddaa91 | ||
|
|
6c96da6eb5 | ||
|
|
c5de5db150 | ||
|
|
0cbe388286 | ||
|
|
e1bf153993 | ||
|
|
bd3bdc3e31 | ||
|
|
0f4acebf05 | ||
|
|
43ace02937 | ||
|
|
f6aaf3e786 | ||
|
|
afcfb6fda8 | ||
|
|
bca7cf2bd9 | ||
|
|
1d07715ebd | ||
|
|
ebfe671988 | ||
|
|
d587dd65a4 | ||
|
|
ce41d34791 | ||
|
|
3fdf0241fc | ||
|
|
7283c8c0ac | ||
|
|
44dbc6809d | ||
|
|
2bb919e634 | ||
|
|
c3dd6a829b | ||
|
|
5c9f30300b | ||
|
|
397d618f1c | ||
|
|
f63cde9354 |
No files matched your search
+109
-48
@@ -1,7 +1,9 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include "gaplessgrid.c"
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||||
|
static const unsigned int gappx = 2; /* gaps between windows */
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
@@ -12,14 +14,23 @@ static const char col_gray2[] = "#444444";
|
|||||||
static const char col_gray3[] = "#bbbbbb";
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
static const char col_gray4[] = "#eeeeee";
|
static const char col_gray4[] = "#eeeeee";
|
||||||
static const char col_cyan[] = "#005577";
|
static const char col_cyan[] = "#005577";
|
||||||
static const char *colors[][3] = {
|
static const char col_border_focus_light[] = "#df8c20"; // hsl(34 75% 50%)
|
||||||
|
static const char col_border_focus_dark[] = "#b25e34"; // hsl(20 55% 45%)
|
||||||
|
static const char *colorsdark[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
[SchemeSel] = { col_gray4, col_cyan, col_border_focus_dark },
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
|
};
|
||||||
|
static const char *colorslight[][3] = {
|
||||||
|
/* fg bg border */
|
||||||
|
[SchemeNorm] = { col_gray1, col_gray3, col_gray2 },
|
||||||
|
[SchemeSel] = { col_cyan, col_gray4, col_border_focus_light },
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
static const char *tags[] = { "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b" };
|
||||||
|
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
/* xprop(1):
|
/* xprop(1):
|
||||||
@@ -43,59 +54,108 @@ static const Layout layouts[] = {
|
|||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
|
{ "HHH", gaplessgrid },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod4Mask
|
||||||
#define TAGKEYS(KEY,TAG) \
|
#define TAGKEYS(KEY,TAG) \
|
||||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
&((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \
|
||||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
&((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \
|
||||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
&((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \
|
||||||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }),
|
||||||
|
|
||||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
static char dmenumon[8] = "0"; /* component of dmenu{dark,light}, manipulated in spawndmenu() */
|
||||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
static const char *dmenudark[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *dmenulight[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray3, "-nf", col_gray1, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *termcmd[] = { "alacritty", NULL };
|
||||||
|
static const char *lockcmd[] = { "slock", NULL };
|
||||||
|
static const char *suspendcmd[] = { "systemctl", "suspend", NULL };
|
||||||
|
static const char *themecmd[] = { "lupan-set-theme", "toggle", NULL };
|
||||||
|
|
||||||
static const Key keys[] = {
|
#include "shift-tools.c"
|
||||||
/* modifier key function argument */
|
#include "exitdwm.c"
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
#include "movestack.c"
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
static Keychord *keychords[] = {
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
/* Keys function argument */
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
&((Keychord){1, {{MODKEY, XK_p}}, spawndmenu, {0} }),
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
&((Keychord){1, {{MODKEY, XK_u}}, shiftview, { .i = +1 } }),
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_u}}, shifttag, { .i = +1 } }),
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_y}}, shifttag, { .i = -1 } }),
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
&((Keychord){1, {{MODKEY, XK_y}}, shiftview, { .i = -1 } }),
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }),
|
||||||
{ MODKEY, XK_Tab, view, {0} },
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_b}}, togglebar, {0} }),
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
&((Keychord){1, {{MODKEY, XK_j}}, focusstackvis, {.i = +1 } }),
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
&((Keychord){1, {{MODKEY, XK_k}}, focusstackvis, {.i = -1 } }),
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
&((Keychord){1, {{MODKEY|ControlMask, XK_j}}, focusstackhid, {.i = +1 } }),
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
&((Keychord){1, {{MODKEY|ControlMask, XK_k}}, focusstackhid, {.i = -1 } }),
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
&((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }),
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_d}}, incnmaster, {.i = -1 } }),
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
&((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }),
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_h}}, shiftboth, {.i = -1} }),
|
||||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
&((Keychord){1, {{MODKEY|ControlMask, XK_h}}, shiftswaptags, {.i = -1} }),
|
||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
&((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }),
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
&((Keychord){1, {{MODKEY|ControlMask, XK_l}}, shiftswaptags, { .i = +1 } }),
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_l}}, shiftboth, { .i = +1 } }),
|
||||||
TAGKEYS( XK_1, 0)
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_j}}, movestack, {.i = +1 } }),
|
||||||
TAGKEYS( XK_2, 1)
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_k}}, movestack, {.i = -1 } }),
|
||||||
TAGKEYS( XK_3, 2)
|
&((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }),
|
||||||
TAGKEYS( XK_4, 3)
|
&((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }),
|
||||||
TAGKEYS( XK_5, 4)
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_w}}, goback, {0} }),
|
||||||
TAGKEYS( XK_6, 5)
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_c}}, killclient, {0} }),
|
||||||
TAGKEYS( XK_7, 6)
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_t}}, setlayout, {.v = &layouts[0]} }),
|
||||||
TAGKEYS( XK_8, 7)
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_f}}, setlayout, {.v = &layouts[1]} }),
|
||||||
TAGKEYS( XK_9, 8)
|
&((Keychord){1, {{MODKEY, XK_m}}, setlayout, {.v = &layouts[2]} }),
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_g}}, setlayout, {.v = &layouts[3]} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_0}}, view, {.ui = ~0 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_s}}, show, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_s}}, showall, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask, XK_s}}, hide, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_q}}, quit, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask|ShiftMask, XK_q}}, quit, {1} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_e}}, exitdwm, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_o}}, winview, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_a}}, gridall, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_r}}, winviewmono, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_s}}, spawn, {.v = suspendcmd } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, XK_l}}, spawn, {.v = lockcmd } }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_t}}, spawn, {.v = themecmd } }),
|
||||||
|
TAGKEYS( XK_q, 0)
|
||||||
|
TAGKEYS( XK_w, 1)
|
||||||
|
TAGKEYS( XK_e, 2)
|
||||||
|
TAGKEYS( XK_r, 3)
|
||||||
|
TAGKEYS( XK_t, 4)
|
||||||
|
TAGKEYS( XK_a, 5)
|
||||||
|
TAGKEYS( XK_s, 6)
|
||||||
|
TAGKEYS( XK_d, 7)
|
||||||
|
TAGKEYS( XK_f, 8)
|
||||||
|
TAGKEYS( XK_g, 9)
|
||||||
|
TAGKEYS( XK_z, 10)
|
||||||
|
TAGKEYS( XK_x, 11)
|
||||||
|
TAGKEYS( XK_c, 12)
|
||||||
|
TAGKEYS( XK_v, 13)
|
||||||
|
TAGKEYS( XK_b, 14)
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_1}}, focusbynum, {.i = 0} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_2}}, focusbynum, {.i = 1} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_3}}, focusbynum, {.i = 2} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_4}}, focusbynum, {.i = 3} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_5}}, focusbynum, {.i = 4} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_6}}, focusbynum, {.i = 5} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_7}}, focusbynum, {.i = 6} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_8}}, focusbynum, {.i = 7} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_9}}, focusbynum, {.i = 8} }),
|
||||||
};
|
};
|
||||||
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
@@ -104,6 +164,7 @@ static const Button buttons[] = {
|
|||||||
/* click event mask button function argument */
|
/* click event mask button function argument */
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include "gaplessgrid.c"
|
||||||
|
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||||
|
static const unsigned int gappx = 2; /* gaps between windows */
|
||||||
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
|
static const char col_gray1[] = "#222222";
|
||||||
|
static const char col_gray2[] = "#444444";
|
||||||
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
|
static const char col_gray4[] = "#eeeeee";
|
||||||
|
static const char col_cyan[] = "#005577";
|
||||||
|
static const char col_border_focus_light[] = "#df8c20"; // hsl(34 75% 50%)
|
||||||
|
static const char col_border_focus_dark[] = "#b25e34"; // hsl(20 55% 45%)
|
||||||
|
static const char *colorsdark[][3] = {
|
||||||
|
/* fg bg border */
|
||||||
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
|
[SchemeSel] = { col_gray4, col_cyan, col_border_focus_dark },
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
|
};
|
||||||
|
static const char *colorslight[][3] = {
|
||||||
|
/* fg bg border */
|
||||||
|
[SchemeNorm] = { col_gray1, col_gray3, col_gray2 },
|
||||||
|
[SchemeSel] = { col_cyan, col_gray4, col_border_focus_light },
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* tagging */
|
||||||
|
static const char *tags[] = { "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b" };
|
||||||
|
|
||||||
|
static const Rule rules[] = {
|
||||||
|
/* xprop(1):
|
||||||
|
* WM_CLASS(STRING) = instance, class
|
||||||
|
* WM_NAME(STRING) = title
|
||||||
|
*/
|
||||||
|
/* class instance title tags mask isfloating monitor */
|
||||||
|
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layout(s) */
|
||||||
|
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||||
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
|
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
|
||||||
|
|
||||||
|
static const Layout layouts[] = {
|
||||||
|
/* symbol arrange function */
|
||||||
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ "[M]", monocle },
|
||||||
|
{ "HHH", gaplessgrid },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* key definitions */
|
||||||
|
#define MODKEY Mod4Mask
|
||||||
|
#define TAGKEYS(KEY,TAG) \
|
||||||
|
&((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }),
|
||||||
|
|
||||||
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
|
/* commands */
|
||||||
|
static char dmenumon[8] = "0"; /* component of dmenu{dark,light}, manipulated in spawndmenu() */
|
||||||
|
static const char *dmenudark[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *dmenulight[] = { "dmenu_run", "-l", "10", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray3, "-nf", col_gray1, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *termcmd[] = { "alacritty", NULL };
|
||||||
|
static const char *lockcmd[] = { "slock", NULL };
|
||||||
|
static const char *suspendcmd[] = { "systemctl", "suspend", NULL };
|
||||||
|
static const char *themecmd[] = { "lupan-set-theme", "toggle", NULL };
|
||||||
|
|
||||||
|
#include "shift-tools.c"
|
||||||
|
#include "exitdwm.c"
|
||||||
|
#include "movestack.c"
|
||||||
|
|
||||||
|
static Keychord *keychords[] = {
|
||||||
|
/* Keys function argument */
|
||||||
|
&((Keychord){1, {{MODKEY, XK_p}}, spawndmenu, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_u}}, shiftview, { .i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_u}}, shifttag, { .i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_y}}, shifttag, { .i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_y}}, shiftview, { .i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_b}}, togglebar, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_j}}, focusstackvis, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_k}}, focusstackvis, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask, XK_j}}, focusstackhid, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask, XK_k}}, focusstackhid, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_d}}, incnmaster, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_h}}, shiftboth, {.i = -1} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask, XK_h}}, shiftswaptags, {.i = -1} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask, XK_l}}, shiftswaptags, { .i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_l}}, shiftboth, { .i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_j}}, movestack, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_k}}, movestack, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_w}}, goback, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_c}}, killclient, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_t}}, setlayout, {.v = &layouts[0]} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_f}}, setlayout, {.v = &layouts[1]} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_m}}, setlayout, {.v = &layouts[2]} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_g}}, setlayout, {.v = &layouts[3]} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_0}}, view, {.ui = ~0 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_s}}, show, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_s}}, showall, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask, XK_s}}, hide, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_q}}, quit, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ControlMask|ShiftMask, XK_q}}, quit, {1} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_e}}, exitdwm, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_o}}, winview, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_a}}, gridall, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_r}}, winviewmono, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_s}}, spawn, {.v = suspendcmd } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, XK_l}}, spawn, {.v = lockcmd } }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {ControlMask|ShiftMask, XK_t}}, spawn, {.v = themecmd } }),
|
||||||
|
TAGKEYS( XK_q, 0)
|
||||||
|
TAGKEYS( XK_w, 1)
|
||||||
|
TAGKEYS( XK_e, 2)
|
||||||
|
TAGKEYS( XK_r, 3)
|
||||||
|
TAGKEYS( XK_t, 4)
|
||||||
|
TAGKEYS( XK_a, 5)
|
||||||
|
TAGKEYS( XK_s, 6)
|
||||||
|
TAGKEYS( XK_d, 7)
|
||||||
|
TAGKEYS( XK_f, 8)
|
||||||
|
TAGKEYS( XK_g, 9)
|
||||||
|
TAGKEYS( XK_z, 10)
|
||||||
|
TAGKEYS( XK_x, 11)
|
||||||
|
TAGKEYS( XK_c, 12)
|
||||||
|
TAGKEYS( XK_v, 13)
|
||||||
|
TAGKEYS( XK_b, 14)
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_1}}, focusbynum, {.i = 0} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_2}}, focusbynum, {.i = 1} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_3}}, focusbynum, {.i = 2} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_4}}, focusbynum, {.i = 3} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_5}}, focusbynum, {.i = 4} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_6}}, focusbynum, {.i = 5} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_7}}, focusbynum, {.i = 6} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_8}}, focusbynum, {.i = 7} }),
|
||||||
|
&((Keychord){1, {{ ControlMask, XK_9}}, focusbynum, {.i = 8} }),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* button definitions */
|
||||||
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
|
static const Button buttons[] = {
|
||||||
|
/* click event mask button function argument */
|
||||||
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
{ ClkTagBar, 0, Button1, view, {0} },
|
||||||
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||||
|
};
|
||||||
|
|
||||||
+124
@@ -0,0 +1,124 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
|
static const char col_gray1[] = "#222222";
|
||||||
|
static const char col_gray2[] = "#444444";
|
||||||
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
|
static const char col_gray4[] = "#eeeeee";
|
||||||
|
static const char col_cyan[] = "#005577";
|
||||||
|
static const char *colors[][3] = {
|
||||||
|
/* fg bg border */
|
||||||
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
|
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* tagging */
|
||||||
|
static const char *tags[] = { "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b" };
|
||||||
|
|
||||||
|
static const Rule rules[] = {
|
||||||
|
/* xprop(1):
|
||||||
|
* WM_CLASS(STRING) = instance, class
|
||||||
|
* WM_NAME(STRING) = title
|
||||||
|
*/
|
||||||
|
/* class instance title tags mask isfloating monitor */
|
||||||
|
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layout(s) */
|
||||||
|
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||||
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
|
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
|
||||||
|
|
||||||
|
static const Layout layouts[] = {
|
||||||
|
/* symbol arrange function */
|
||||||
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ "[M]", monocle },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* key definitions */
|
||||||
|
#define MODKEY Mod4Mask
|
||||||
|
#define TAGKEYS(KEY,TAG) \
|
||||||
|
&((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \
|
||||||
|
&((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }),
|
||||||
|
|
||||||
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
|
/* commands */
|
||||||
|
static char dmenumon[8]; /* component of dmenucmd, manipulated in spawn() */
|
||||||
|
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *termcmd[] = { "alacritty", NULL };
|
||||||
|
|
||||||
|
static Keychord *keychords[] = {
|
||||||
|
/* Keys function argument */
|
||||||
|
&((Keychord){1, {{MODKEY, XK_p}}, spawn, {.v = dmenucmd } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_e}}, spawn, {.v = termcmd } }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_b}}, togglebar, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_j}}, focusstack, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_k}}, focusstack, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_u}}, incnmaster, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_c}}, killclient, {0} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_t}}, setlayout, {.v = &layouts[0]} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_f}}, setlayout, {.v = &layouts[1]} }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {0, XK_m}}, setlayout, {.v = &layouts[2]} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_y}}, view, {.ui = ~0 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }),
|
||||||
|
&((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }),
|
||||||
|
&((Keychord){2, {{MODKEY, XK_semicolon}, {MODKEY|ShiftMask, XK_q}}, quit, {0} }),
|
||||||
|
TAGKEYS( XK_q, 0)
|
||||||
|
TAGKEYS( XK_w, 1)
|
||||||
|
TAGKEYS( XK_e, 2)
|
||||||
|
TAGKEYS( XK_r, 3)
|
||||||
|
TAGKEYS( XK_t, 4)
|
||||||
|
TAGKEYS( XK_a, 5)
|
||||||
|
TAGKEYS( XK_s, 6)
|
||||||
|
TAGKEYS( XK_d, 7)
|
||||||
|
TAGKEYS( XK_f, 8)
|
||||||
|
TAGKEYS( XK_g, 9)
|
||||||
|
TAGKEYS( XK_z, 10)
|
||||||
|
TAGKEYS( XK_x, 11)
|
||||||
|
TAGKEYS( XK_c, 12)
|
||||||
|
TAGKEYS( XK_v, 13)
|
||||||
|
TAGKEYS( XK_b, 14)
|
||||||
|
};
|
||||||
|
|
||||||
|
/* button definitions */
|
||||||
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
|
static const Button buttons[] = {
|
||||||
|
/* click event mask button function argument */
|
||||||
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
{ ClkTagBar, 0, Button1, view, {0} },
|
||||||
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 6.7
|
VERSION = 6.8
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,272 @@
|
|||||||
|
From 9c020a20a2e1091e8b47edfea5e8795d8b451bc9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lukasz Kasprzak <lukas@labunix.xyz>
|
||||||
|
Date: Fri, 17 Jul 2026 15:45:22 +0200
|
||||||
|
Subject: [PATCH] keychord: bind a sequence of keys, and dispatch events while
|
||||||
|
waiting
|
||||||
|
|
||||||
|
Original keychord patch by Hai Nguyen <hhai2105@gmail.com>, updated for
|
||||||
|
dwm 6.4+ grabkeys() by Aaron Zueger <contact@azureorange.xyz>. This
|
||||||
|
revision rebases onto dwm 6.8 and fixes an event-loss bug in the chord
|
||||||
|
wait loop.
|
||||||
|
|
||||||
|
The wait loop used to discard every event that was not a KeyPress:
|
||||||
|
|
||||||
|
while (running && !XNextEvent(dpy, &event) && !ran)
|
||||||
|
if(event.type == KeyPress)
|
||||||
|
break;
|
||||||
|
|
||||||
|
Two consequences, both reproduced on Xephyr:
|
||||||
|
|
||||||
|
1. Unrecoverable input freeze. grabbuttons() grabs unfocused clients
|
||||||
|
GrabModeSync/GrabModeSync, so clicking one freezes pointer AND
|
||||||
|
keyboard until the grabbing client calls XAllowEvents. dwm does that
|
||||||
|
in buttonpress() -- but if the ButtonPress is discarded here,
|
||||||
|
buttonpress() never runs. The grab stays frozen forever and the loop
|
||||||
|
can never exit, because a frozen keyboard cannot deliver the KeyPress
|
||||||
|
it is waiting for. Only killing dwm ends it; XSendEvent is discarded
|
||||||
|
by this same loop and XTEST queues behind the frozen device.
|
||||||
|
Repro: press a chord prefix, then click any unfocused client.
|
||||||
|
Observed: XGrabKeyboard -> GrabFrozen, XQueryPointer -> Button1 held.
|
||||||
|
|
||||||
|
2. Orphaned windows. A MapRequest arriving mid-chord is dropped, so a
|
||||||
|
window opening during a chord is never managed. DestroyNotify,
|
||||||
|
Expose and ConfigureRequest are lost the same way.
|
||||||
|
|
||||||
|
Dispatch through handler[] as run() does, breaking on KeyPress before
|
||||||
|
dispatch so keypress() cannot recurse. The `&& !ran` term is dropped:
|
||||||
|
ran is always 0 on entry and nothing in the body can set it.
|
||||||
|
---
|
||||||
|
config.def.h | 81 ++++++++++++++++++++++++++--------------------------
|
||||||
|
dwm.c | 79 +++++++++++++++++++++++++++++++++++++++++---------
|
||||||
|
2 files changed, 106 insertions(+), 54 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 81c3fc0..7c7ec36 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -47,11 +47,11 @@ static const Layout layouts[] = {
|
||||||
|
|
||||||
|
/* key definitions */
|
||||||
|
#define MODKEY Mod1Mask
|
||||||
|
-#define TAGKEYS(KEY,TAG) \
|
||||||
|
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||||
|
- { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||||
|
- { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||||
|
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||||
|
+#define TAGKEYS(KEY,TAG) \
|
||||||
|
+ &((Keychord){1, {{MODKEY, KEY}}, view, {.ui = 1 << TAG} }), \
|
||||||
|
+ &((Keychord){1, {{MODKEY|ControlMask, KEY}}, toggleview, {.ui = 1 << TAG} }), \
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, KEY}}, tag, {.ui = 1 << TAG} }), \
|
||||||
|
+ &((Keychord){1, {{MODKEY|ControlMask|ShiftMask, KEY}}, toggletag, {.ui = 1 << TAG} }),
|
||||||
|
|
||||||
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
@@ -61,41 +61,42 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
|
||||||
|
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
|
-static const Key keys[] = {
|
||||||
|
- /* modifier key function argument */
|
||||||
|
- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
|
- { MODKEY, XK_b, togglebar, {0} },
|
||||||
|
- { MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
|
- { MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
|
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
|
- { MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
- { MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
|
- { MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
|
- { MODKEY, XK_Return, zoom, {0} },
|
||||||
|
- { MODKEY, XK_Tab, view, {0} },
|
||||||
|
- { MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
|
- { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
|
- { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
|
- { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
- { MODKEY, XK_space, setlayout, {0} },
|
||||||
|
- { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
- { MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||||
|
- { MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||||
|
- { MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
|
- { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
|
- { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
- TAGKEYS( XK_1, 0)
|
||||||
|
- TAGKEYS( XK_2, 1)
|
||||||
|
- TAGKEYS( XK_3, 2)
|
||||||
|
- TAGKEYS( XK_4, 3)
|
||||||
|
- TAGKEYS( XK_5, 4)
|
||||||
|
- TAGKEYS( XK_6, 5)
|
||||||
|
- TAGKEYS( XK_7, 6)
|
||||||
|
- TAGKEYS( XK_8, 7)
|
||||||
|
- TAGKEYS( XK_9, 8)
|
||||||
|
- { MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||||
|
+static Keychord *keychords[] = {
|
||||||
|
+ /* Keys function argument */
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_p}}, spawn, {.v = dmenucmd } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_Return}}, spawn, {.v = termcmd } }),
|
||||||
|
+ &((Keychord){2, {{MODKEY, XK_e}, {MODKEY, XK_e}}, spawn, {.v = termcmd } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_b}}, togglebar, {0} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_j}}, focusstack, {.i = +1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_k}}, focusstack, {.i = -1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_i}}, incnmaster, {.i = +1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_d}}, incnmaster, {.i = -1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_h}}, setmfact, {.f = -0.05} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_l}}, setmfact, {.f = +0.05} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_Return}}, zoom, {0} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_Tab}}, view, {0} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_c}}, killclient, {0} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_t}}, setlayout, {.v = &layouts[0]} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_f}}, setlayout, {.v = &layouts[1]} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_m}}, setlayout, {.v = &layouts[2]} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_space}}, setlayout, {0} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_space}}, togglefloating, {0} }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_0}}, view, {.ui = ~0 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_0}}, tag, {.ui = ~0 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_comma}}, focusmon, {.i = -1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY, XK_period}}, focusmon, {.i = +1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_comma}}, tagmon, {.i = -1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_period}}, tagmon, {.i = +1 } }),
|
||||||
|
+ &((Keychord){1, {{MODKEY|ShiftMask, XK_q}}, quit, {0} }),
|
||||||
|
+ TAGKEYS( XK_1, 0)
|
||||||
|
+ TAGKEYS( XK_2, 1)
|
||||||
|
+ TAGKEYS( XK_3, 2)
|
||||||
|
+ TAGKEYS( XK_4, 3)
|
||||||
|
+ TAGKEYS( XK_5, 4)
|
||||||
|
+ TAGKEYS( XK_6, 5)
|
||||||
|
+ TAGKEYS( XK_7, 6)
|
||||||
|
+ TAGKEYS( XK_8, 7)
|
||||||
|
+ TAGKEYS( XK_9, 8)
|
||||||
|
};
|
||||||
|
|
||||||
|
/* button definitions */
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 53b393e..243b12c 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -101,9 +101,14 @@ struct Client {
|
||||||
|
typedef struct {
|
||||||
|
unsigned int mod;
|
||||||
|
KeySym keysym;
|
||||||
|
+} Key;
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ unsigned int n;
|
||||||
|
+ const Key keys[5];
|
||||||
|
void (*func)(const Arg *);
|
||||||
|
const Arg arg;
|
||||||
|
-} Key;
|
||||||
|
+} Keychord;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *symbol;
|
||||||
|
@@ -266,6 +271,7 @@ static Display *dpy;
|
||||||
|
static Drw *drw;
|
||||||
|
static Monitor *mons, *selmon;
|
||||||
|
static Window root, wmcheckwin;
|
||||||
|
+unsigned int currentkey = 0;
|
||||||
|
|
||||||
|
/* configuration, allows nested code to access above variables */
|
||||||
|
#include "config.h"
|
||||||
|
@@ -954,7 +960,8 @@ grabkeys(void)
|
||||||
|
{
|
||||||
|
updatenumlockmask();
|
||||||
|
{
|
||||||
|
- unsigned int i, j, k;
|
||||||
|
+ /* unsigned int i, j, k; */
|
||||||
|
+ unsigned int i, c, k;
|
||||||
|
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||||
|
int start, end, skip;
|
||||||
|
KeySym *syms;
|
||||||
|
@@ -964,15 +971,18 @@ grabkeys(void)
|
||||||
|
syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
|
||||||
|
if (!syms)
|
||||||
|
return;
|
||||||
|
+
|
||||||
|
for (k = start; k <= end; k++)
|
||||||
|
- for (i = 0; i < LENGTH(keys); i++)
|
||||||
|
+ for (i = 0; i < LENGTH(keychords); i++)
|
||||||
|
/* skip modifier codes, we do that ourselves */
|
||||||
|
- if (keys[i].keysym == syms[(k - start) * skip])
|
||||||
|
- for (j = 0; j < LENGTH(modifiers); j++)
|
||||||
|
+ if (keychords[i]->keys[currentkey].keysym == syms[(k - start) * skip])
|
||||||
|
+ for (c = 0; c < LENGTH(modifiers); c++)
|
||||||
|
XGrabKey(dpy, k,
|
||||||
|
- keys[i].mod | modifiers[j],
|
||||||
|
+ keychords[i]->keys[currentkey].mod | modifiers[c],
|
||||||
|
root, True,
|
||||||
|
GrabModeAsync, GrabModeAsync);
|
||||||
|
+ if(currentkey > 0)
|
||||||
|
+ XGrabKey(dpy, XKeysymToKeycode(dpy, XK_Escape), AnyModifier, root, True, GrabModeAsync, GrabModeAsync);
|
||||||
|
XFree(syms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -999,17 +1009,58 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
|
||||||
|
void
|
||||||
|
keypress(XEvent *e)
|
||||||
|
{
|
||||||
|
- unsigned int i;
|
||||||
|
+ /* unsigned int i; */
|
||||||
|
+ XEvent event = *e;
|
||||||
|
+ unsigned int ran = 0;
|
||||||
|
KeySym keysym;
|
||||||
|
XKeyEvent *ev;
|
||||||
|
|
||||||
|
- ev = &e->xkey;
|
||||||
|
- keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||||
|
- for (i = 0; i < LENGTH(keys); i++)
|
||||||
|
- if (keysym == keys[i].keysym
|
||||||
|
- && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
|
||||||
|
- && keys[i].func)
|
||||||
|
- keys[i].func(&(keys[i].arg));
|
||||||
|
+ Keychord *arr1[sizeof(keychords) / sizeof(Keychord*)];
|
||||||
|
+ Keychord *arr2[sizeof(keychords) / sizeof(Keychord*)];
|
||||||
|
+ memcpy(arr1, keychords, sizeof(keychords));
|
||||||
|
+ Keychord **rpointer = arr1;
|
||||||
|
+ Keychord **wpointer = arr2;
|
||||||
|
+
|
||||||
|
+ size_t r = sizeof(keychords)/ sizeof(Keychord*);
|
||||||
|
+
|
||||||
|
+ while(1){
|
||||||
|
+ ev = &event.xkey;
|
||||||
|
+ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||||
|
+ size_t w = 0;
|
||||||
|
+ for (int i = 0; i < r; i++){
|
||||||
|
+ if(keysym == (*(rpointer + i))->keys[currentkey].keysym
|
||||||
|
+ && CLEANMASK((*(rpointer + i))->keys[currentkey].mod) == CLEANMASK(ev->state)
|
||||||
|
+ && (*(rpointer + i))->func){
|
||||||
|
+ if((*(rpointer + i))->n == currentkey +1){
|
||||||
|
+ (*(rpointer + i))->func(&((*(rpointer + i))->arg));
|
||||||
|
+ ran = 1;
|
||||||
|
+ }else{
|
||||||
|
+ *(wpointer + w) = *(rpointer + i);
|
||||||
|
+ w++;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ currentkey++;
|
||||||
|
+ if(w == 0 || ran == 1)
|
||||||
|
+ break;
|
||||||
|
+ grabkeys();
|
||||||
|
+ /* Events arriving mid-chord must be dispatched, not dropped:
|
||||||
|
+ * discarding a ButtonPress that activated the GrabModeSync grab
|
||||||
|
+ * from grabbuttons() freezes pointer and keyboard permanently,
|
||||||
|
+ * since only buttonpress()'s XAllowEvents can release it. */
|
||||||
|
+ while (running && !XNextEvent(dpy, &event)) {
|
||||||
|
+ if (event.type == KeyPress)
|
||||||
|
+ break;
|
||||||
|
+ if (handler[event.type])
|
||||||
|
+ handler[event.type](&event); /* call handler */
|
||||||
|
+ }
|
||||||
|
+ r = w;
|
||||||
|
+ Keychord **holder = rpointer;
|
||||||
|
+ rpointer = wpointer;
|
||||||
|
+ wpointer = holder;
|
||||||
|
+ }
|
||||||
|
+ currentkey = 0;
|
||||||
|
+ grabkeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
--
|
||||||
|
2.47.3
|
||||||
|
|
||||||
@@ -110,6 +110,9 @@ Increase master area size.
|
|||||||
.B Mod1\-h
|
.B Mod1\-h
|
||||||
Decrease master area size.
|
Decrease master area size.
|
||||||
.TP
|
.TP
|
||||||
|
.B Mod1\-o
|
||||||
|
Select view of the window in focus. The list of tags to be displayed is matched to the window tag list.
|
||||||
|
.TP
|
||||||
.B Mod1\-Return
|
.B Mod1\-Return
|
||||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||||
.TP
|
.TP
|
||||||
@@ -142,6 +145,9 @@ Add/remove all windows with nth tag to/from the view.
|
|||||||
.TP
|
.TP
|
||||||
.B Mod1\-Shift\-q
|
.B Mod1\-Shift\-q
|
||||||
Quit dwm.
|
Quit dwm.
|
||||||
|
.TP
|
||||||
|
.B Mod1\-Control\-Shift\-q
|
||||||
|
Restart dwm.
|
||||||
.SS Mouse commands
|
.SS Mouse commands
|
||||||
.TP
|
.TP
|
||||||
.B Mod1\-Button1
|
.B Mod1\-Button1
|
||||||
@@ -155,6 +161,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
|
|||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
|
.SH SIGNALS
|
||||||
|
.TP
|
||||||
|
.B SIGHUP - 1
|
||||||
|
Restart the dwm process.
|
||||||
|
.TP
|
||||||
|
.B SIGTERM - 15
|
||||||
|
Cleanly terminate the dwm process.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dmenu (1),
|
.BR dmenu (1),
|
||||||
.BR st (1)
|
.BR st (1)
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
# include <stdio.h>
|
||||||
|
# include <string.h>
|
||||||
|
|
||||||
|
void exitdwm ()
|
||||||
|
{
|
||||||
|
# if \
|
||||||
|
defined S_LOCK || \
|
||||||
|
defined S_RESTART_DWM || \
|
||||||
|
defined S_OFFSCREEN || \
|
||||||
|
defined S_EXIT || \
|
||||||
|
defined S_REBOOT || \
|
||||||
|
defined S_SHUTDOWN || \
|
||||||
|
defined S_LOCK_ICON || \
|
||||||
|
defined S_RESTART_DWM_ICON || \
|
||||||
|
defined S_OFFSCREEN_ICON || \
|
||||||
|
defined S_EXIT_ICON || \
|
||||||
|
defined S_REBOOT_ICON || \
|
||||||
|
defined S_SHUTDOWN_ICON || \
|
||||||
|
defined S_FORMAT || \
|
||||||
|
defined S_FORMAT_CLEAR
|
||||||
|
# error (conflicting macro names)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define S_LOCK "Lock"
|
||||||
|
# define S_RESTART_DWM "restart Dwm"
|
||||||
|
# define S_OFFSCREEN "Off-screen"
|
||||||
|
# define S_EXIT "Exit"
|
||||||
|
# define S_REBOOT "Reboot"
|
||||||
|
# define S_SHUTDOWN "Shutdown"
|
||||||
|
# define S_LOCK_ICON "\uf023" // <= FontAwesome icons
|
||||||
|
# define S_RESTART_DWM_ICON "\uf01e"
|
||||||
|
# define S_OFFSCREEN_ICON "\uf108"
|
||||||
|
# define S_EXIT_ICON "\uf2f5"
|
||||||
|
# define S_REBOOT_ICON "\uf021"
|
||||||
|
# define S_SHUTDOWN_ICON "\uf011"
|
||||||
|
|
||||||
|
# define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION
|
||||||
|
# define S_FORMAT_CLEAR "sed 's/^..//'"
|
||||||
|
|
||||||
|
FILE * exit_menu = popen (
|
||||||
|
"echo \""
|
||||||
|
S_FORMAT (LOCK) "\n"
|
||||||
|
S_FORMAT (RESTART_DWM) "\n"
|
||||||
|
S_FORMAT (OFFSCREEN) "\n"
|
||||||
|
S_FORMAT (EXIT) "\n"
|
||||||
|
S_FORMAT (REBOOT) "\n"
|
||||||
|
S_FORMAT (SHUTDOWN)
|
||||||
|
"\" | dmenu -p exit: | " S_FORMAT_CLEAR
|
||||||
|
,
|
||||||
|
"r"
|
||||||
|
);
|
||||||
|
|
||||||
|
char exit_action [16];
|
||||||
|
|
||||||
|
if (
|
||||||
|
exit_menu == NULL ||
|
||||||
|
fscanf (exit_menu, "%15[a-zA-Z -]", exit_action) == EOF
|
||||||
|
) {
|
||||||
|
fputs ("Error. Failure in exit_dwm.", stderr);
|
||||||
|
goto close_streams;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp (exit_action, S_LOCK) == 0) system ("slock & sleep .5; xset dpms force off");
|
||||||
|
else if (strcmp (exit_action, S_RESTART_DWM) == 0) quit (& (const Arg) {1});
|
||||||
|
else if (strcmp (exit_action, S_OFFSCREEN) == 0) system ("sleep .5; xset dpms force off");
|
||||||
|
else if (strcmp (exit_action, S_EXIT) == 0) quit (& (const Arg) {0});
|
||||||
|
else if (strcmp (exit_action, S_REBOOT) == 0) system ("systemctl reboot");
|
||||||
|
else if (strcmp (exit_action, S_SHUTDOWN) == 0) system ("systemctl poweroff -i");
|
||||||
|
|
||||||
|
close_streams:
|
||||||
|
pclose (exit_menu);
|
||||||
|
|
||||||
|
# undef S_LOCK
|
||||||
|
# undef S_RESTART_DWM
|
||||||
|
# undef S_OFFSCREEN
|
||||||
|
# undef S_EXIT
|
||||||
|
# undef S_REBOOT
|
||||||
|
# undef S_SHUTDOWN
|
||||||
|
# undef S_LOCK_ICON
|
||||||
|
# undef S_RESTART_DWM_ICON
|
||||||
|
# undef S_OFFSCREEN_ICON
|
||||||
|
# undef S_EXIT_ICON
|
||||||
|
# undef S_REBOOT_ICON
|
||||||
|
# undef S_SHUTDOWN_ICON
|
||||||
|
# undef S_FORMAT
|
||||||
|
# undef S_FORMAT_CLEAR
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
void
|
||||||
|
gaplessgrid(Monitor *m) {
|
||||||
|
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
|
||||||
|
if(n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for(cols = 0; cols <= n/2; cols++)
|
||||||
|
if(cols*cols >= n)
|
||||||
|
break;
|
||||||
|
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||||
|
cols = 2;
|
||||||
|
rows = n/cols;
|
||||||
|
|
||||||
|
/* window geometries */
|
||||||
|
cw = cols ? m->ww / cols : m->ww;
|
||||||
|
cn = 0; /* current column number */
|
||||||
|
rn = 0; /* current row number */
|
||||||
|
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
||||||
|
if(i/rows + 1 > cols - n%cols)
|
||||||
|
rows = n/cols + 1;
|
||||||
|
ch = rows ? m->wh / rows : m->wh;
|
||||||
|
cx = m->wx + cn*cw;
|
||||||
|
cy = m->wy + rn*ch;
|
||||||
|
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
|
||||||
|
rn++;
|
||||||
|
if(rn >= rows) {
|
||||||
|
rn = 0;
|
||||||
|
cn++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
void
|
||||||
|
movestack(const Arg *arg) {
|
||||||
|
Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
||||||
|
|
||||||
|
if(arg->i > 0) {
|
||||||
|
/* find the client after selmon->sel */
|
||||||
|
for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
if(!c)
|
||||||
|
for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* find the client before selmon->sel */
|
||||||
|
for(i = selmon->clients; i != selmon->sel; i = i->next)
|
||||||
|
if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
c = i;
|
||||||
|
if(!c)
|
||||||
|
for(; i; i = i->next)
|
||||||
|
if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
c = i;
|
||||||
|
}
|
||||||
|
/* find the client before selmon->sel and c */
|
||||||
|
for(i = selmon->clients; i && (!p || !pc); i = i->next) {
|
||||||
|
if(i->next == selmon->sel)
|
||||||
|
p = i;
|
||||||
|
if(i->next == c)
|
||||||
|
pc = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* swap c and selmon->sel selmon->clients in the selmon->clients list */
|
||||||
|
if(c && c != selmon->sel) {
|
||||||
|
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
|
||||||
|
selmon->sel->next = c->next==selmon->sel?c:c->next;
|
||||||
|
c->next = temp;
|
||||||
|
|
||||||
|
if(p && p != c)
|
||||||
|
p->next = c;
|
||||||
|
if(pc && pc != selmon->sel)
|
||||||
|
pc->next = selmon->sel;
|
||||||
|
|
||||||
|
if(selmon->sel == selmon->clients)
|
||||||
|
selmon->clients = c;
|
||||||
|
else if(c == selmon->clients)
|
||||||
|
selmon->clients = selmon->sel;
|
||||||
|
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
}
|
||||||
+135
@@ -0,0 +1,135 @@
|
|||||||
|
/* Sends a window to the next/prev tag */
|
||||||
|
void
|
||||||
|
shifttag(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
tag(&shifted);
|
||||||
|
}
|
||||||
|
/* Sends a window to the next/prev tag that has a client, else it moves it to the next/prev one. */
|
||||||
|
void
|
||||||
|
shifttagclients(const Arg *arg)
|
||||||
|
{
|
||||||
|
|
||||||
|
Arg shifted;
|
||||||
|
Client *c;
|
||||||
|
unsigned int tagmask = 0;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
for (c = selmon->clients; c; c = c->next)
|
||||||
|
if (!(c->tags))
|
||||||
|
tagmask = tagmask | c->tags;
|
||||||
|
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui << arg->i)
|
||||||
|
| (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
else /* right circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i)
|
||||||
|
| shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
tag(&shifted);
|
||||||
|
}
|
||||||
|
/* Navigate to the next/prev tag */
|
||||||
|
void
|
||||||
|
shiftview(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = (shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
/* Navigate to the next/prev tag that has a client, else moves it to the next/prev tag */
|
||||||
|
void
|
||||||
|
shiftviewclients(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
Client *c;
|
||||||
|
unsigned int tagmask = 0;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
for (c = selmon->clients; c; c = c->next)
|
||||||
|
if (!(c->tags))
|
||||||
|
tagmask = tagmask | c->tags;
|
||||||
|
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui << arg->i)
|
||||||
|
| (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
else /* right circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i)
|
||||||
|
| shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
/* move the current active window to the next/prev tag and view it. More like following the window */
|
||||||
|
void
|
||||||
|
shiftboth(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i)));
|
||||||
|
tag(&shifted);
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
//helper function for shiftswaptags.
|
||||||
|
//see: https://github.com/moizifty/DWM-Build/blob/65379c62640788881486401a0d8c79333751b02f/config.h#L48
|
||||||
|
void
|
||||||
|
swaptags(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
unsigned int newtag = arg->ui & TAGMASK;
|
||||||
|
unsigned int curtag = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (newtag == curtag || !curtag || (curtag & (curtag-1)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (c = selmon->clients; c != NULL; c = c->next) {
|
||||||
|
if ((c->tags & newtag) || (c->tags & curtag))
|
||||||
|
c->tags ^= curtag ^ newtag;
|
||||||
|
|
||||||
|
if (!c->tags)
|
||||||
|
c->tags = newtag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//move to the swaped tag
|
||||||
|
//selmon->tagset[selmon->seltags] = newtag;
|
||||||
|
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
/* swaps "tags" (all the clients) with the next/prev tag. */
|
||||||
|
void
|
||||||
|
shiftswaptags(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i)));
|
||||||
|
swaptags(&shifted);
|
||||||
|
// uncomment if you also want to "go" (view) the tag where the the clients are going
|
||||||
|
//view(&shifted);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user