[wiki] [sites] [dwm] add scratchpad patch || parazyd

From: <git_AT_suckless.org>
Date: Tue, 07 Feb 2017 13:12:52 +0100

commit 9ee4be35da9ce8c4dbdda35c240da1968eba13ad
Author: parazyd <parazyd_AT_dyne.org>
Date: Tue Feb 7 13:11:55 2017 +0100

    [dwm] add scratchpad patch

diff --git a/dwm.suckless.org/patches/dwm-scratchpad-20170207-bb3bd6f.diff b/dwm.suckless.org/patches/dwm-scratchpad-20170207-bb3bd6f.diff
new file mode 100644
index 0000000..b9e104c
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-scratchpad-20170207-bb3bd6f.diff
_AT_@ -0,0 +1,83 @@
+diff --git a/config.def.h b/config.def.h
+index ba9a240..eaaca3e 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -58,11 +58,14 @@ static const Layout layouts[] = {
+ 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 char scratchpadname[] = "scratchpad";
++static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
+
+ static Key keys[] = {
+ /* modifier key function argument */
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+ { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
++ { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
+ { MODKEY, XK_b, togglebar, {0} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+diff --git a/dwm.c b/dwm.c
+index d27cb67..3fa7274 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -212,6 +212,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
++static void togglescratch(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unfocus(Client *c, int setfocus);
+_AT_@ -272,6 +273,8 @@ static Window root, wmcheckwin;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
++static unsigned int scratchtag = 1 << LENGTH(tags);
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+_AT_@ -1051,6 +1054,13 @@ manage(Window w, XWindowAttributes *wa)
+ && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+ c->bw = borderpx;
+
++ if (!strcmp(c->name, scratchpadname)) {
++ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
++ c->isfloating = True;
++ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
++ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
++ }
++
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
+_AT_@ -1724,6 +1734,28 @@ togglefloating(const Arg *arg)
+ }
+
+ void
++togglescratch(const Arg *arg)
++{
++ Client *c;
++ unsigned int found = 0;
++
++ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
++ if (found) {
++ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
++ if (newtagset) {
++ selmon->tagset[selmon->seltags] = newtagset;
++ focus(NULL);
++ arrange(selmon);
++ }
++ if (ISVISIBLE(c)) {
++ focus(c);
++ restack(selmon);
++ }
++ } else
++ spawn(arg);
++}
++
++void
+ toggletag(const Arg *arg)
+ {
+ unsigned int newtags;
diff --git a/dwm.suckless.org/patches/scratchpad.md b/dwm.suckless.org/patches/scratchpad.md
new file mode 100644
index 0000000..1350ce9
--- /dev/null
+++ b/dwm.suckless.org/patches/scratchpad.md
_AT_@ -0,0 +1,24 @@
+scratchpad
+==========
+
+Description
+-----------
+
+The scratchpad patch allows you to spawn or restore a floating terminal
+window. It is usually useful to have one to do some short typing.
+
+A tool like detach (http://detach.sourceforge.net) turns it into a
+launchpad for X applications.
+
+By default your terminal (st) is used, and the default key binding is
+`MODKEY+XK_grave`. A `config.def.h` change is included in the patch.
+
+Download
+--------
+
+* [dwm-scratchpad-20170207-bb3bd6f.diff](dwm-scratchpad-20170207-bb3bd6f.diff)
+
+Author
+------
+
+* Ivan J. <parazyd_AT_dyne.org>
Received on Tue Feb 07 2017 - 13:12:52 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 07 2017 - 13:24:16 CET