aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2022-11-12 18:05:21 -0700
committerBryson Steck <brysonsteck@protonmail.com>2022-11-12 18:05:21 -0700
commit7516b03d7d3c7844ebdab69cf731d59ea2b3c84d (patch)
tree4c380f744f1c389ddc030a377332e4b4cbb0b816
parent4da4ae80e489b477ec9913317a209f9ad8f9256a (diff)
downloaddwm-7516b03d7d3c7844ebdab69cf731d59ea2b3c84d.tar
dwm-7516b03d7d3c7844ebdab69cf731d59ea2b3c84d.tar.gz
dwm-7516b03d7d3c7844ebdab69cf731d59ea2b3c84d.tar.bz2
add bstack and fixed config format
-rw-r--r--config.def.h4
-rw-r--r--config.h18
-rw-r--r--dwm.c64
3 files changed, 78 insertions, 8 deletions
diff --git a/config.def.h b/config.def.h
index 08cfbd4..773262f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -43,6 +43,8 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "TTT", bstack },
+ { "===", bstackhoriz },
};
/* key definitions */
@@ -78,6 +80,8 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
diff --git a/config.h b/config.h
index cb43db5..eaee5e4 100644
--- a/config.h
+++ b/config.h
@@ -57,6 +57,8 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "TTT", bstack },
+ { "===", bstackhoriz },
};
/* key definitions */
@@ -74,16 +76,15 @@ static const Layout layouts[] = {
/* commands */
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", bg_normal, "-nf", fg, "-sb", bg_selected, "-sf", fg, NULL };
static const char *dmenucmd[] = { "dmenu_run_history", "-m", dmenumon, "-fn", dmenufont, "-nb", bg_normal, "-nf", fg, "-sb", bg_selected, "-sf", fg, NULL };
-//static const char *termcmd[] = { "st", NULL };
static const char *termcmd[] = { "spawn-alacritty.sh", NULL };
static const char *brightnessup[] = { "brightness-up.sh", NULL };
static const char *brightnessdown[] = { "brightness-down.sh", NULL };
static const char *screenshooter[] = { "screenshot.sh", NULL };
static const char *volup[] = { "volup.sh", NULL };
static const char *voldown[] = { "voldown.sh", NULL };
-//static const char *volmute[] = { "volmute.sh", NULL }; (replaced with *next[] for different keyboards)
+//static const char *firefox[] = { "firefox-bin", NULL };
static const char *firefox[] = { "librewolf-bin", NULL };
static const char *slock[] = { "slock", NULL };
static const char *playpause[] = { "playerctl", "play-pause", NULL };
@@ -98,7 +99,6 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_f, spawn, {.v = firefox } },
{ MODKEY|ShiftMask, XK_Escape, spawn, {.v = slock } },
{ MODKEY, XK_b, togglebar, {0} },
-// { MODKEY, XK_w, tabmode, {-1} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
@@ -111,6 +111,8 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
@@ -127,10 +129,10 @@ static Key keys[] = {
{ MODKEY, XK_Print, spawn, {.v = screenshooter } },
{ MODKEY, XK_F10, spawn, {.v = voldown } },
{ MODKEY, XK_F11, spawn, {.v = volup } },
- { MODKEY, XK_F7, spawn, {.v = previous } },
- { MODKEY, XK_F8, spawn, {.v = playpause } },
- { MODKEY, XK_F9, spawn, {.v = next } },
- { MODKEY|ShiftMask, XK_k, spawn, {.v = keepass } },
+ { MODKEY, XK_F7, spawn, {.v = previous } },
+ { MODKEY, XK_F8, spawn, {.v = playpause } },
+ { MODKEY, XK_F9, spawn, {.v = next } },
+ { MODKEY|ShiftMask, XK_k, spawn, {.v = keepass } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
diff --git a/dwm.c b/dwm.c
index 30db5af..19ff3a0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -237,6 +237,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static void bstack(Monitor *m);
+static void bstackhoriz(Monitor *m);
/* variables */
static const char broken[] = "broken";
@@ -2185,3 +2187,65 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
+
+static void
+bstack(Monitor *m) {
+ int w, h, mh, mx, tx, ty, tw;
+ unsigned int i, n;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+ if (n > m->nmaster) {
+ mh = m->nmaster ? m->mfact * m->wh : 0;
+ tw = m->ww / (n - m->nmaster);
+ ty = m->wy + mh;
+ } else {
+ mh = m->wh;
+ tw = m->ww;
+ ty = m->wy;
+ }
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ h = m->wh - mh;
+ resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
+ if (tw != m->ww)
+ tx += WIDTH(c);
+ }
+ }
+}
+
+static void
+bstackhoriz(Monitor *m) {
+ int w, mh, mx, tx, ty, th;
+ unsigned int i, n;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+ if (n > m->nmaster) {
+ mh = m->nmaster ? m->mfact * m->wh : 0;
+ th = (m->wh - mh) / (n - m->nmaster);
+ ty = m->wy + mh;
+ } else {
+ th = mh = m->wh;
+ ty = m->wy;
+ }
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
+ if (th != m->wh)
+ ty += HEIGHT(c);
+ }
+ }
+}