1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
From d2efb5e19eb466f77f0860f0175b84247799bb93 Mon Sep 17 00:00:00 2001
From: Alex Cole <ajzcole@airmail.cc>
Date: Sat, 14 Nov 2020 21:03:09 +1300
Subject: [PATCH] splitstatus patch
---
config.def.h | 2 ++
dwm.c | 31 +++++++++++++++----------------
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..4161652 100644
--- a/config.def.h
+++ b/config.def.h
@@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
+static const int splitstatus = 1; /* 1 for split status items */
+static const char *splitdelim = ";"; /* Character used for separating status */
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
diff --git a/dwm.c b/dwm.c
index 664c527..e1a8085 100644
--- a/dwm.c
+++ b/dwm.c
@@ -701,13 +701,9 @@ drawbar(Monitor *m)
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
-
- /* draw status first so it can be overdrawn by tags later */
- if (m == selmon) { /* status is only drawn on selected monitor */
- drw_setscheme(drw, scheme[SchemeNorm]);
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
- }
+ char *mstext;
+ char *rstext;
+ int msx;
for (c = m->clients; c; c = c->next) {
occ |= c->tags;
@@ -729,17 +725,20 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
- if ((w = m->ww - tw - x) > bh) {
- if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
- if (m->sel->isfloating)
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
- } else {
- drw_setscheme(drw, scheme[SchemeNorm]);
- drw_rect(drw, x, 0, w, bh, 1, 1);
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, x, 0, m->ww - x, bh, 1, 1);
+
+ if (m == selmon) { /* status is only drawn on selected monitor */
+ rstext = strdup(stext);
+ if (splitstatus) {
+ mstext = strsep(&rstext, splitdelim);
+ msx = (m->ww - TEXTW(mstext) + lrpad) / 2; /* x position of middle status text */
+ drw_text(drw, msx, 0, TEXTW(mstext) - lrpad, bh, 0, mstext, 0);
}
+ tw = TEXTW(rstext) - lrpad + 2; /* 2px right padding */
+ drw_text(drw, m->ww - tw, 0, tw, bh, 0, rstext, 0);
}
+
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}
--
2.29.2
|