mirror of
https://github.com/bakkeby/patches
synced 2024-11-19 15:25:38 +00:00
96 lines
2.7 KiB
Diff
96 lines
2.7 KiB
Diff
From 4bd473cd0894e26b24294d41b70165e608b61de7 Mon Sep 17 00:00:00 2001
|
|
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..0ad5375 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, *mon;
|
|
+ unsigned int mi, 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 (mi = 0, mon = mons; mon; mon = mon->next, mi++);
|
|
+ for (j = 0; j < LENGTH(monrules); j++) {
|
|
+ mr = &monrules[j];
|
|
+ if ((mr->monitor == -1 || mr->monitor == mi)) {
|
|
+ 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
|
|
|