added scratchpad patch

This commit is contained in:
Ryan Kes 2019-03-05 18:27:39 +01:00
parent 64aa1771db
commit fb43f762bc
3 changed files with 90 additions and 2 deletions

View file

@ -23,6 +23,7 @@ _patches=(
"local-hide_vacant_tags-git-20160626-7af4d43.diff" "local-hide_vacant_tags-git-20160626-7af4d43.diff"
"local-statuscolors-20181008-b69c870.diff" "local-statuscolors-20181008-b69c870.diff"
"local-fancybar-2019018-b69c870.diff" "local-fancybar-2019018-b69c870.diff"
"local-scratchpad-20170207-bb3bd6f.diff"
) )
source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz
@ -31,7 +32,7 @@ source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz
"${_patches[@]}") "${_patches[@]}")
md5sums=('9929845ccdec4d2cc191f16210dd7f3d' md5sums=('9929845ccdec4d2cc191f16210dd7f3d'
'ad8b5866ac139c7ca7ee050b56799c3c' '80b0fe720d05a2c2b0c5ee6c8baaf45d'
'939f403a71b6e85261d09fc3412269ee' '939f403a71b6e85261d09fc3412269ee'
'2c19f1a3db59e158c45483668f4cee24' '2c19f1a3db59e158c45483668f4cee24'
'fbb786263f2d714b18368ff64779d669' 'fbb786263f2d714b18368ff64779d669'
@ -42,7 +43,8 @@ md5sums=('9929845ccdec4d2cc191f16210dd7f3d'
'aa3d5f3c45057a2a6ee73aede3fc218a' 'aa3d5f3c45057a2a6ee73aede3fc218a'
'd2781ac29048fc50e42e0f11e6cf7bce' 'd2781ac29048fc50e42e0f11e6cf7bce'
'c5469c1457955a8447e05ec5118b3ce6' 'c5469c1457955a8447e05ec5118b3ce6'
'77e3bfab2270dde73caf4e1b14566386') '77e3bfab2270dde73caf4e1b14566386'
'7381051e12596394791092f0d39a2dd2')
prepare() { prepare() {
cd $srcdir/$pkgname-$pkgver cd $srcdir/$pkgname-$pkgver

View file

@ -106,6 +106,8 @@ static const Layout layouts[] = {
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ 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 *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 *termcmd[] = { "st", NULL };
static const char scratchpadname[] = "scratchpad";
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
#include "selfrestart.c" #include "selfrestart.c"
@ -113,6 +115,7 @@ static Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ 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_grave, togglescratch, {.v = scratchpadcmd } },
{ MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } },

View file

@ -0,0 +1,83 @@
diff -up a/config.def.h b/config.def.h
--- a/config.def.h
+++ b/config.def.h
@@ -72,6 +72,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 +81,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, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
diff -up a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -246,6 +246,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);
@@ -312,6 +313,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]; };
@@ -1238,6 +1241,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);
@@ -2013,6 +2023,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;