2
0
mirror of https://github.com/bakkeby/patches synced 2024-11-09 13:10:41 +00:00
patches/dwm/dwm-monitorrules-6.2.diff

96 lines
2.7 KiB
Diff
Raw Normal View History

From e21382979ef624bd15952d7228f0fb878d21bcb0 Mon Sep 17 00:00:00 2001
2020-04-26 09:43:33 +00:00
From: bakkeby <bakkeby@gmail.com>
Date: Sun, 26 Apr 2020 10:49:08 +0200
Subject: [PATCH] Monitor rules patch
This patch allows the user to define layout, mfact, nmaster, showbar,
and topbar settings on a per monitor basis. An example use case could
be to have a layout with a horizontal split for a secondary vertical
monitor.
---
config.def.h | 6 ++++++
dwm.c | 36 ++++++++++++++++++++++++++++++++----
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..b81f377 100644
--- a/config.def.h
+++ b/config.def.h
@@ -31,6 +31,12 @@ static const Rule rules[] = {
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
};
+static const MonitorRule monrules[] = {
+ /* monitor layout mfact nmaster showbar topbar */
+ { 1, 2, -1, -1, -1, -1 }, // use a different layout for the second monitor
+ { -1, 0, -1, -1, -1, -1 }, // default
+};
+
/* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
diff --git a/dwm.c b/dwm.c
index 4465af1..0b33335 100644
--- a/dwm.c
+++ b/dwm.c
@@ -141,6 +141,15 @@ typedef struct {
int monitor;
} Rule;
+typedef struct {
+ int monitor;
+ int layout;
+ float mfact;
+ int nmaster;
+ int showbar;
+ int topbar;
+} MonitorRule;
+
/* function declarations */
static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@@ -630,7 +639,9 @@ configurerequest(XEvent *e)
Monitor *
createmon(void)
{
- Monitor *m;
+ Monitor *m, *mi;
+ unsigned int mc, j;
+ const MonitorRule *mr;
m = ecalloc(1, sizeof(Monitor));
m->tagset[0] = m->tagset[1] = 1;
@@ -638,9 +649,26 @@ createmon(void)
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
- m->lt[0] = &layouts[0];
- m->lt[1] = &layouts[1 % LENGTH(layouts)];
- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+
+ for (mc = 0, mi = mons; mi; mi = mi->next, mc++);
+ for (j = 0; j < LENGTH(monrules); j++) {
+ mr = &monrules[j];
+ if ((mr->monitor == -1 || mr->monitor == mc)) {
+ m->lt[0] = &layouts[mr->layout];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[mr->layout].symbol, sizeof m->ltsymbol);
+
+ if (mr->mfact > -1)
+ m->mfact = mr->mfact;
+ if (mr->nmaster > -1)
+ m->nmaster = mr->nmaster;
+ if (mr->showbar > -1)
+ m->showbar = mr->showbar;
+ if (mr->topbar > -1)
+ m->topbar = mr->topbar;
+ break;
+ }
+ }
return m;
}
--
2.19.1
2020-04-26 09:43:33 +00:00