expandible scratchpad patch

super+shift+return for dropdown terminal

super+' for dropdown calculator
This commit is contained in:
Luke Smith 2020-04-26 12:34:14 -04:00
parent 206a4a3833
commit 806bb2a2bf
No known key found for this signature in database
GPG key ID: 4C50B54A911F6252
3 changed files with 60 additions and 6 deletions

View file

@ -11,7 +11,7 @@ static const int smartgaps = 0; /* 1 means no outer gap when the
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10", "JoyPixels:pixelsize=10:antialias=true:autohint=true" }; static const char *fonts[] = { "monospace:size=10", "JoyPixels:pixelsize=10:antialias=true:autohint=true" };
static char dmenufont[] = "monospace:size=10"; static char dmenufont[] = "monospace:size=10";
static char normbgcolor[] = "#222222"; static char normbgcolor[] = "#222222";
static char normbordercolor[] = "#444444"; static char normbordercolor[] = "#444444";
static char normfgcolor[] = "#bbbbbb"; static char normfgcolor[] = "#bbbbbb";
@ -24,6 +24,18 @@ static char *colors[][3] = {
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
}; };
typedef struct {
const char *name;
const void *cmd;
} Sp;
const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
const char *spcmd2[] = {"st", "-n", "spcalc", "-f", "monospace:size=16", "-g", "50x20", "-e", "bc", "-lq", NULL };
static Sp scratchpads[] = {
/* name cmd */
{"spterm", spcmd1},
{"spranger", spcmd2},
};
/* tagging */ /* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@ -35,6 +47,8 @@ static const Rule rules[] = {
/* class instance title tags mask isfloating isterminal noswallow monitor */ /* class instance title tags mask isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, { "Gimp", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
{ "St", NULL, NULL, 0, 0, 1, 0, -1 }, { "St", NULL, NULL, 0, 0, 1, 0, -1 },
{ NULL, "spterm", NULL, SPTAG(0), 1, 1, 0, -1 },
{ NULL, "spcalc", NULL, SPTAG(1), 1, 1, 0, -1 },
}; };
/* layout(s) */ /* layout(s) */
@ -156,10 +170,10 @@ static Key keys[] = {
{ MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_semicolon, shiftview, { .i = 1 } }, { MODKEY, XK_semicolon, shiftview, { .i = 1 } },
/* { MODKEY|ShiftMask, XK_semicolon, shiftview, SHCMD("") }, */ /* { MODKEY|ShiftMask, XK_semicolon, shiftview, SHCMD("") }, */
/* { MODKEY, XK_apostrophe, spawn, SHCMD("") }, */ { MODKEY, XK_apostrophe, togglescratch, {.ui = 1} },
/* { MODKEY|ShiftMask, XK_apostrophe, spawn, SHCMD("") }, */ /* { MODKEY|ShiftMask, XK_apostrophe, spawn, SHCMD("") }, */
{ MODKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } },
/* { MODKEY|ShiftMask, XK_Return, togglescratch, {.v = scratchpadcmd } }, */ { MODKEY|ShiftMask, XK_Return, togglescratch, {.ui = 0} },
{ MODKEY, XK_z, incrgaps, {.i = +1 } }, { MODKEY, XK_z, incrgaps, {.i = +1 } },
{ MODKEY|ShiftMask, XK_z, incrgaps, {.i = -1 } }, { MODKEY|ShiftMask, XK_z, incrgaps, {.i = -1 } },
@ -255,7 +269,6 @@ static Key keys[] = {
/* { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, */ /* { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, */
/* { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, */ /* { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, */
}; };
/* button definitions */ /* button definitions */

43
dwm.c
View file

@ -62,7 +62,10 @@
#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M)) #define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))
#define WIDTH(X) ((X)->w + 2 * (X)->bw) #define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1) #define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
#define TAGMASK ((1 << NUMTAGS) - 1)
#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#define TRUNC(X,A,B) (MAX((A), MIN((X), (B)))) #define TRUNC(X,A,B) (MAX((A), MIN((X), (B))))
#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \ #define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \
@ -251,6 +254,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
static void togglebar(const Arg *arg); static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglescratch(const Arg *arg);
static void togglesticky(const Arg *arg); static void togglesticky(const Arg *arg);
static void togglefullscr(const Arg *arg); static void togglefullscr(const Arg *arg);
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
@ -356,6 +360,11 @@ applyrules(Client *c)
c->isterminal = r->isterminal; c->isterminal = r->isterminal;
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->tags |= r->tags; c->tags |= r->tags;
if ((r->tags & SPTAGMASK) && r->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
}
for (m = mons; m && m->num != r->monitor; m = m->next); for (m = mons; m && m->num != r->monitor; m = m->next);
if (m) if (m)
c->mon = m; c->mon = m;
@ -365,7 +374,7 @@ applyrules(Client *c)
XFree(ch.res_class); XFree(ch.res_class);
if (ch.res_name) if (ch.res_name)
XFree(ch.res_name); XFree(ch.res_name);
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags]; c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
} }
int int
@ -1854,6 +1863,10 @@ showhide(Client *c)
if (!c) if (!c)
return; return;
if (ISVISIBLE(c)) { if (ISVISIBLE(c)) {
if ((c->tags & SPTAGMASK) && c->isfloating) {
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
}
/* show clients top down */ /* show clients top down */
XMoveWindow(dpy, c->win, c->x, c->y); XMoveWindow(dpy, c->win, c->x, c->y);
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
@ -1978,6 +1991,32 @@ togglesticky(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
togglescratch(const Arg *arg)
{
Client *c;
unsigned int found = 0;
unsigned int scratchtag = SPTAG(arg->ui);
Arg sparg = {.v = scratchpads[arg->ui].cmd};
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 {
selmon->tagset[selmon->seltags] |= scratchtag;
spawn(&sparg);
}
}
void void
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {

View file

@ -166,6 +166,8 @@ To type capital letters, hold down the \f(CWShift\fP key\(emthat might sound lik
\f(CWMod+F4\fP \(en pulsemixer (audio system control) \f(CWMod+F4\fP \(en pulsemixer (audio system control)
.ITEM .ITEM
\f(CWMod+Shift+Enter\fP \(en Show/hide dropdown terminal \f(CWMod+Shift+Enter\fP \(en Show/hide dropdown terminal
.ITEM
\f(CWMod+'\fP \(en Show/hide dropdown calculator
.LIST OFF .LIST OFF
.HEADING 2 "System" .HEADING 2 "System"
.LI .LI