mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding scratchpad patch
This commit is contained in:
parent
ed1c509df3
commit
2eb8bcdf15
@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
|
||||
### Changelog:
|
||||
|
||||
2019-10-10 - Added mdpcontrol patch
|
||||
2019-10-10 - Added mdpcontrol and scratchpad patches
|
||||
|
||||
2019-10-08 - Added columns layout and fakefullscreen patch
|
||||
|
||||
@ -202,6 +202,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
- saves size and position of every floating window before it is forced into tiled mode
|
||||
- if the window is made floating again then the old dimensions will be restored
|
||||
|
||||
- [scratchpad](https://dwm.suckless.org/patches/scratchpad/)
|
||||
- the scratchpad patch allows you to spawn or restore a floating terminal window
|
||||
|
||||
- [selfrestart](https://dwm.suckless.org/patches/selfrestart/)
|
||||
- restart dwm without the unnecessary dependency of an external script
|
||||
|
||||
|
@ -393,10 +393,18 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
#if SCRATCHPAD_PATCH
|
||||
static const char scratchpadname[] = "scratchpad";
|
||||
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
|
||||
#endif // SCRATCHPAD_PATCH
|
||||
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
#if SCRATCHPAD_PATCH
|
||||
{ MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
|
||||
#endif // SCRATCHPAD_PATCH
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
|
13
dwm.c
13
dwm.c
@ -1882,6 +1882,16 @@ manage(Window w, XWindowAttributes *wa)
|
||||
c->bw = borderpx;
|
||||
#endif // SETBORDERPX_PATCH
|
||||
|
||||
#if SCRATCHPAD_PATCH
|
||||
selmon->tagset[selmon->seltags] &= ~scratchtag;
|
||||
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);
|
||||
}
|
||||
#endif // SCRATCHPAD_PATCH
|
||||
|
||||
wc.border_width = c->bw;
|
||||
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
|
||||
#if FLOAT_BORDER_COLOR_PATCH
|
||||
@ -2799,6 +2809,9 @@ spawn(const Arg *arg)
|
||||
{
|
||||
if (arg->v == dmenucmd)
|
||||
dmenumon[0] = '0' + selmon->num;
|
||||
#if SCRATCHPAD_PATCH
|
||||
selmon->tagset[selmon->seltags] &= ~scratchtag;
|
||||
#endif // SCRATCHPAD_PATCH
|
||||
if (fork() == 0) {
|
||||
if (dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
|
@ -94,6 +94,10 @@
|
||||
#include "rotatestack.c"
|
||||
#endif
|
||||
|
||||
#if SCRATCHPAD_PATCH
|
||||
#include "scratchpad.c"
|
||||
#endif
|
||||
|
||||
#if SELFRESTART_PATCH
|
||||
#include "selfrestart.c"
|
||||
#endif
|
||||
|
@ -94,6 +94,10 @@
|
||||
#include "rotatestack.h"
|
||||
#endif
|
||||
|
||||
#if SCRATCHPAD_PATCH
|
||||
#include "scratchpad.h"
|
||||
#endif
|
||||
|
||||
#if SELFRESTART_PATCH
|
||||
#include "selfrestart.h"
|
||||
#endif
|
||||
|
23
patch/scratchpad.c
Normal file
23
patch/scratchpad.c
Normal file
@ -0,0 +1,23 @@
|
||||
static unsigned int scratchtag = 1 << LENGTH(tags);
|
||||
|
||||
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);
|
||||
}
|
1
patch/scratchpad.h
Normal file
1
patch/scratchpad.h
Normal file
@ -0,0 +1 @@
|
||||
static void togglescratch(const Arg *arg);
|
@ -310,6 +310,12 @@
|
||||
*/
|
||||
#define SAVEFLOATS_PATCH 0
|
||||
|
||||
/* The scratchpad patch allows you to spawn or restore a floating terminal window.
|
||||
* It is typically useful when one need to do some short typing.
|
||||
* https://dwm.suckless.org/patches/scratchpad/
|
||||
*/
|
||||
#define SCRATCHPAD_PATCH 0
|
||||
|
||||
/* Allows restarting dwm without the dependency of an external script.
|
||||
* https://dwm.suckless.org/patches/selfrestart/
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user