diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2024-08-17 13:30:57 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2024-08-17 13:30:57 +0400 |
commit | acabd59afb742821f2d1ca535e3d4efce0632f20 (patch) | |
tree | 778b9c53f0a7a890300bf74cbb02f265df33ea39 | |
parent | e70b0cffddf227a01b7085f97e74c847e205e93c (diff) |
scratchpad patched and keybinds added
-rw-r--r-- | config.h | 6 | ||||
-rw-r--r-- | dwm.c | 34 |
2 files changed, 40 insertions, 0 deletions
@@ -69,6 +69,9 @@ 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 *browsercmd[] = { "qutebrowser", NULL }; +static const char scratchpadname[] = "scratchpad"; +static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "70x24", NULL }; + static const char *light_up[] = {"slight", "-i", "5", NULL}, @@ -104,6 +107,9 @@ static const Key keys[] = { { MODKEY, XK_minus, setgaps, {.i = -1 } }, { MODKEY, XK_equal, setgaps, {.i = +1 } }, + { MODKEY, XK_s, togglescratch, {.v = scratchpadcmd } }, + + { 0 , XF86XK_MonBrightnessUp , spawn , {.v = light_up}}, { 0 , XF86XK_MonBrightnessDown, spawn , {.v = light_down}}, { 0 , XF86XK_AudioLowerVolume, spawn , {.v = vol_down}}, @@ -213,6 +213,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglescratch(const Arg *arg); static void togglefullscr(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); @@ -274,6 +275,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]; }; @@ -1072,6 +1075,14 @@ manage(Window w, XWindowAttributes *wa) c->y = MAX(c->y, c->mon->wy); c->bw = borderpx; + 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); + } + wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); @@ -1657,6 +1668,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)); @@ -1752,6 +1764,28 @@ togglefullscr(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; |