summaryrefslogtreecommitdiff
path: root/dwm/patches/dwm-scratchpad-6.2.diff
diff options
context:
space:
mode:
Diffstat (limited to 'dwm/patches/dwm-scratchpad-6.2.diff')
-rw-r--r--dwm/patches/dwm-scratchpad-6.2.diff90
1 files changed, 90 insertions, 0 deletions
diff --git a/dwm/patches/dwm-scratchpad-6.2.diff b/dwm/patches/dwm-scratchpad-6.2.diff
new file mode 100644
index 0000000..2062263
--- /dev/null
+++ b/dwm/patches/dwm-scratchpad-6.2.diff
@@ -0,0 +1,90 @@
1diff -up a/config.def.h b/config.def.h
2--- a/config.def.h 2019-06-06 21:23:27.006661784 +0200
3+++ b/config.def.h 2019-06-20 15:05:59.083102462 +0200
4@@ -58,11 +58,14 @@ static const Layout layouts[] = {
5 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
6 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
7 static const char *termcmd[] = { "st", NULL };
8+static const char scratchpadname[] = "scratchpad";
9+static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
10
11 static Key keys[] = {
12 /* modifier key function argument */
13 { MODKEY, XK_p, spawn, {.v = dmenucmd } },
14 { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
15+ { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
16 { MODKEY, XK_b, togglebar, {0} },
17 { MODKEY, XK_j, focusstack, {.i = +1 } },
18 { MODKEY, XK_k, focusstack, {.i = -1 } },
19diff -up a/dwm.c b/dwm.c
20--- a/dwm.c 2019-06-06 21:23:27.023328450 +0200
21+++ b/dwm.c 2019-06-20 15:07:01.089767947 +0200
22@@ -213,6 +213,7 @@ static void tagmon(const Arg *arg);
23 static void tile(Monitor *);
24 static void togglebar(const Arg *arg);
25 static void togglefloating(const Arg *arg);
26+static void togglescratch(const Arg *arg);
27 static void toggletag(const Arg *arg);
28 static void toggleview(const Arg *arg);
29 static void unfocus(Client *c, int setfocus);
30@@ -273,6 +274,8 @@ static Window root, wmcheckwin;
31 /* configuration, allows nested code to access above variables */
32 #include "config.h"
33
34+static unsigned int scratchtag = 1 << LENGTH(tags);
35+
36 /* compile-time check if all tags fit into an unsigned int bit array. */
37 struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
38
39@@ -1052,6 +1055,14 @@ manage(Window w, XWindowAttributes *wa)
40 && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
41 c->bw = borderpx;
42
43+ selmon->tagset[selmon->seltags] &= ~scratchtag;
44+ if (!strcmp(c->name, scratchpadname)) {
45+ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
46+ c->isfloating = True;
47+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
48+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
49+ }
50+
51 wc.border_width = c->bw;
52 XConfigureWindow(dpy, w, CWBorderWidth, &wc);
53 XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
54@@ -1661,6 +1672,7 @@ spawn(const Arg *arg)
55 {
56 if (arg->v == dmenucmd)
57 dmenumon[0] = '0' + selmon->num;
58+ selmon->tagset[selmon->seltags] &= ~scratchtag;
59 if (fork() == 0) {
60 if (dpy)
61 close(ConnectionNumber(dpy));
62@@ -1748,6 +1760,28 @@ togglefloating(const Arg *arg)
63 }
64
65 void
66+togglescratch(const Arg *arg)
67+{
68+ Client *c;
69+ unsigned int found = 0;
70+
71+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
72+ if (found) {
73+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
74+ if (newtagset) {
75+ selmon->tagset[selmon->seltags] = newtagset;
76+ focus(NULL);
77+ arrange(selmon);
78+ }
79+ if (ISVISIBLE(c)) {
80+ focus(c);
81+ restack(selmon);
82+ }
83+ } else
84+ spawn(arg);
85+}
86+
87+void
88 toggletag(const Arg *arg)
89 {
90 unsigned int newtags;