2020-12-01 10:20:51 +00:00
|
|
|
diff -up -N a/config.def.h b/config.def.h
|
|
|
|
--- a/config.def.h 2020-12-01 11:12:09.214062117 +0100
|
|
|
|
+++ b/config.def.h 2020-12-01 11:15:20.540986211 +0100
|
|
|
|
@@ -72,6 +74,8 @@ 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 };
|
|
|
|
|
|
|
|
#include "selfrestart.c"
|
|
|
|
|
|
|
|
@@ -79,6 +83,7 @@ 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|ShiftMask, XK_j, rotatestack, {.i = +1 } },
|
|
|
|
{ MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } },
|
2019-03-05 17:27:39 +00:00
|
|
|
diff -up a/dwm.c b/dwm.c
|
2020-12-01 09:52:26 +00:00
|
|
|
--- a/dwm.c 2019-06-06 21:23:27.023328450 +0200
|
|
|
|
+++ b/dwm.c 2019-06-20 15:07:01.089767947 +0200
|
|
|
|
@@ -213,6 +213,7 @@ static void tagmon(const Arg *arg);
|
2019-03-05 17:27:39 +00:00
|
|
|
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);
|
2020-12-01 09:52:26 +00:00
|
|
|
@@ -273,6 +274,8 @@ static Window root, wmcheckwin;
|
2019-03-05 17:27:39 +00:00
|
|
|
/* configuration, allows nested code to access above variables */
|
|
|
|
#include "config.h"
|
2020-12-01 10:20:51 +00:00
|
|
|
|
2019-03-05 17:27:39 +00:00
|
|
|
+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]; };
|
2020-12-01 10:20:51 +00:00
|
|
|
|
2020-12-01 09:52:26 +00:00
|
|
|
@@ -1052,6 +1055,14 @@ manage(Window w, XWindowAttributes *wa)
|
2019-03-05 17:27:39 +00:00
|
|
|
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
|
|
|
|
c->bw = borderpx;
|
2020-12-01 10:20:51 +00:00
|
|
|
|
2020-12-01 09:52:26 +00:00
|
|
|
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
|
2019-03-05 17:27:39 +00:00
|
|
|
+ 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);
|
2020-12-01 09:52:26 +00:00
|
|
|
@@ -1661,6 +1672,7 @@ spawn(const Arg *arg)
|
|
|
|
{
|
|
|
|
if (arg->v == dmenucmd)
|
|
|
|
dmenumon[0] = '0' + selmon->num;
|
|
|
|
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
|
|
|
|
if (fork() == 0) {
|
|
|
|
if (dpy)
|
|
|
|
close(ConnectionNumber(dpy));
|
|
|
|
@@ -1748,6 +1760,28 @@ togglefloating(const Arg *arg)
|
2019-03-05 17:27:39 +00:00
|
|
|
}
|
2020-12-01 10:20:51 +00:00
|
|
|
|
2019-03-05 17:27:39 +00:00
|
|
|
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;
|