mirror of
https://github.com/zoriya/dwm.git
synced 2026-06-03 02:52:10 +00:00
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.
This commit is contained in:
@@ -101,6 +101,12 @@ static const BarRule barrules[] = {
|
||||
{ 'A', 0, BAR_ALIGN_RIGHT, width_status2d, draw_status2d, click_statuscmd, "status2d" },
|
||||
{ 'A', 0, BAR_ALIGN_RIGHT, width_systray, draw_systray, click_systray, "systray" },
|
||||
{ -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
|
||||
}
|
||||
|
||||
static const MonitorRule monrules[] = {
|
||||
/* monitor layout mfact nmaster showbar tagset */
|
||||
{ -1, 0, -1, -1, -1, 0 }, // default
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
|
||||
@@ -88,8 +88,8 @@ static const Rule rules[] = {
|
||||
RULE(.type = WTYPE "SPLASH", .isfloating = 1)
|
||||
RULE(.class = "feh", .tags = 0)
|
||||
// RULE(.class = "kitty", .isterminal = 1)
|
||||
RULE(.title = "Discord Updater", .tags = 1 << 4, .isfloating = 1, .matchonce = 1, .floatpos = "50% 50%", .monitor = 1)
|
||||
RULE(.class = "discord", .tags = 1 << 4, .monitor = 1)
|
||||
RULE(.title = "Discord Updater", .tags = 1 << 4, .isfloating = 1, .matchonce = 1, .floatpos = "50% 50%")
|
||||
RULE(.class = "discord", .tags = 1 << 4)
|
||||
RULE(.class = "lutris", .isfloating = 1)
|
||||
};
|
||||
|
||||
@@ -123,6 +123,13 @@ static const BarRule barrules[] = {
|
||||
{ -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
|
||||
};
|
||||
|
||||
static const MonitorRule monrules[] = {
|
||||
/* monitor layout mfact nmaster showbar tagset */
|
||||
{ 1, 0, -1, -1, -1, 1 << 5 },
|
||||
{ 2, 0, -1, -1, -1, 1 << 4 },
|
||||
{ -1, 0, -1, -1, -1, 0 }, // default
|
||||
};
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* See LICENSE file for copyright and license details.
|
||||
/* See LICENSE file for cpyright and license details.
|
||||
*
|
||||
* dynamic window manager is designed like any other X client as well. It is
|
||||
* driven through handling X events. In contrast to other X clients, a window
|
||||
@@ -242,6 +242,15 @@ struct Clientlist {
|
||||
Client *stack;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int monitor;
|
||||
int layout;
|
||||
float mfact;
|
||||
int nmaster;
|
||||
int showbar;
|
||||
unsigned int tagset;
|
||||
} MonitorRule;
|
||||
|
||||
/* function declarations */
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
@@ -898,6 +907,8 @@ createmon(void)
|
||||
|
||||
const BarRule *br;
|
||||
Bar *bar;
|
||||
unsigned int j;
|
||||
const MonitorRule *mr;
|
||||
|
||||
/* bail out if the number of monitors exceeds the number of tags */
|
||||
for (i=1, tm=mons; tm; i++, tm=tm->next);
|
||||
@@ -926,9 +937,6 @@ createmon(void)
|
||||
m->showbar = showbar;
|
||||
|
||||
for (mi = 0, mon = mons; mon; mon = mon->next, mi++); // monitor index
|
||||
m->lt[0] = &layouts[0];
|
||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||
|
||||
/* Derive the number of bars for this monitor based on bar rules */
|
||||
for (n = -1, i = 0; i < LENGTH(barrules); i++) {
|
||||
@@ -947,6 +955,24 @@ createmon(void)
|
||||
istopbar = !istopbar;
|
||||
}
|
||||
|
||||
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->tagset)
|
||||
m->tagset[m->seltags] = mr->tagset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user