diff --git a/config.h b/config.h index 3a0c3bc..ed08b39 100644 --- a/config.h +++ b/config.h @@ -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 topbar = 1; /* 0 means bottom bar */ 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 normbordercolor[] = "#444444"; static char normfgcolor[] = "#bbbbbb"; @@ -24,6 +24,18 @@ static char *colors[][3] = { [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 */ 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 */ { "Gimp", NULL, NULL, 1 << 8, 0, 0, 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) */ @@ -156,10 +170,10 @@ static Key keys[] = { { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_semicolon, shiftview, { .i = 1 } }, /* { MODKEY|ShiftMask, XK_semicolon, shiftview, SHCMD("") }, */ - /* { MODKEY, XK_apostrophe, spawn, SHCMD("") }, */ + { MODKEY, XK_apostrophe, togglescratch, {.ui = 1} }, /* { MODKEY|ShiftMask, XK_apostrophe, spawn, SHCMD("") }, */ { 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|ShiftMask, XK_z, incrgaps, {.i = -1 } }, @@ -255,7 +269,6 @@ static Key keys[] = { /* { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, */ /* { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, */ - }; /* button definitions */ diff --git a/dwm.c b/dwm.c index ddf9dd8..a3e5fd8 100644 --- a/dwm.c +++ b/dwm.c @@ -62,7 +62,10 @@ #define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M)) #define WIDTH(X) ((X)->w + 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 TRUNC(X,A,B) (MAX((A), MIN((X), (B)))) #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 togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglescratch(const Arg *arg); static void togglesticky(const Arg *arg); static void togglefullscr(const Arg *arg); static void toggletag(const Arg *arg); @@ -356,6 +360,11 @@ applyrules(Client *c) c->isterminal = r->isterminal; c->isfloating = r->isfloating; 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); if (m) c->mon = m; @@ -365,7 +374,7 @@ applyrules(Client *c) XFree(ch.res_class); if (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 @@ -1854,6 +1863,10 @@ showhide(Client *c) if (!c) return; 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 */ XMoveWindow(dpy, c->win, c->x, c->y); if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) @@ -1978,6 +1991,32 @@ togglesticky(const Arg *arg) 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 toggletag(const Arg *arg) { diff --git a/larbs.mom b/larbs.mom index c671856..59de7fd 100644 --- a/larbs.mom +++ b/larbs.mom @@ -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) .ITEM \f(CWMod+Shift+Enter\fP \(en Show/hide dropdown terminal +.ITEM +\f(CWMod+'\fP \(en Show/hide dropdown calculator .LIST OFF .HEADING 2 "System" .LI