commit d20f6b10f6a50bd01f13ad31ad7d792bafccdb28
parent 38341da3257fbf5d602897b655cef472ad918a95
Author: kocotian <kocotian@kocotian.pl>
Date: Sat, 12 Dec 2020 14:19:47 +0100
status
Diffstat:
7 files changed, 114 insertions(+), 17 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -6,6 +6,7 @@ static const unsigned int snap = 32; /* snap pixel */
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
+static const char statussep = ';'; /* separator between status bars */
static const int barheight = 25; /* height of a bar; 0 equals autocalculation */
static const int attachdirection = 0; /* 0 default, 1 above, 2 aside, 3 below, 4 bottom, 5 top */
static const char *fonts[] = { "monospace:size=8", "JoyPixels:pixelsize=10:antialias=true:autohint=true" };
diff --git a/config.def.h b/config.def.h.orig
diff --git a/config.def.h.rej b/config.def.h.rej
@@ -0,0 +1,15 @@
+--- config.def.h
++++ config.def.h
+@@ -5,6 +5,7 @@ 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 char statussep = ';'; /* separator between status bars */
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
+ static const char col_gray1[] = "#222222";
+@@ -112,4 +113,3 @@ static Button buttons[] = {
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
+ };
+-
diff --git a/dwm.c b/dwm.c
@@ -135,6 +135,7 @@ struct Monitor {
int nmaster;
int num;
int by; /* bar geometry */
+ int eby; /* extra bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
unsigned int seltags;
@@ -147,6 +148,7 @@ struct Monitor {
Client *stack;
Monitor *next;
Window barwin;
+ Window extrabarwin;
const Layout *lt[2];
Pertag *pertag;
};
@@ -285,8 +287,9 @@ static pid_t winpid(Window w);
/* variables */
static const char broken[] = "broken";
-static char stext[256];
-static char rawstext[256];
+static char stext[2048];
+static char estext[2048];
+static char rawstext[2048];
static int dwmblockssig;
pid_t dwmblockspid = 0;
static int screen;
@@ -702,7 +705,9 @@ cleanupmon(Monitor *mon)
m->next = mon->next;
}
XUnmapWindow(dpy, mon->barwin);
+ XUnmapWindow(dpy, mon->extrabarwin);
XDestroyWindow(dpy, mon->barwin);
+ XDestroyWindow(dpy, mon->extrabarwin);
free(mon);
}
@@ -765,6 +770,7 @@ configurenotify(XEvent *e)
if (c->isfullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh);
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
+ XMoveResizeWindow(dpy, m->extrabarwin, m->wx, m->eby, m->ww, bh);
}
focus(NULL);
arrange(NULL);
@@ -984,6 +990,16 @@ drawbar(Monitor *m)
}
}
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
+
+ if (m == selmon) { /* extra status is only drawn on selected monitor */
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_text(drw, 0, 0, mons->ww, bh, 0, estext, 0);
+ drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
+ } else {
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_text(drw, 0, 0, mons->ww, bh, 0, "", 0);
+ drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
+ }
}
void
@@ -2160,6 +2176,7 @@ togglebar(const Arg *arg)
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+ XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh);
arrange(selmon);
}
@@ -2315,14 +2332,22 @@ updatebars(void)
};
XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
- if (m->barwin)
- continue;
- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
- CopyFromParent, DefaultVisual(dpy, screen),
- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
- XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
- XMapRaised(dpy, m->barwin);
- XSetClassHint(dpy, m->barwin, &ch);
+ if (!m->barwin) {
+ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
+ CopyFromParent, DefaultVisual(dpy, screen),
+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+ XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
+ XMapRaised(dpy, m->barwin);
+ XSetClassHint(dpy, m->barwin, &ch);
+ }
+ if (!m->extrabarwin) {
+ m->extrabarwin = XCreateWindow(dpy, root, m->wx, m->eby, m->ww, bh, 0, DefaultDepth(dpy, screen),
+ CopyFromParent, DefaultVisual(dpy, screen),
+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+ XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor);
+ XMapRaised(dpy, m->extrabarwin);
+ XSetClassHint(dpy, m->extrabarwin, &ch);
+ }
}
}
@@ -2331,12 +2356,15 @@ updatebarpos(Monitor *m)
{
m->wy = m->my;
m->wh = m->mh;
+ m->wh -= bh * m->showbar * 2;
+ m->wy = m->showbar ? m->wy + bh : m->wy;
if (m->showbar) {
- m->wh -= bh;
- m->by = m->topbar ? m->wy : m->wy + m->wh;
- m->wy = m->topbar ? m->wy + bh : m->wy;
- } else
+ m->by = m->topbar ? m->wy - bh : m->wy + m->wh;
+ m->eby = m->topbar ? m->wy + m->wh : m->wy - bh;
+ } else {
m->by = -bh;
+ m->eby = -bh;
+ }
}
void
@@ -2509,7 +2537,7 @@ updatesizehints(Client *c)
}
void
-updatestatus(void)
+updatestatusorig(void)
{
if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext)))
strcpy(stext, "dwm-"VERSION);
@@ -2519,6 +2547,27 @@ updatestatus(void)
}
void
+updatestatus(void)
+{
+ char qtext[4096];
+ if (!gettextprop(root, XA_WM_NAME, qtext, sizeof(qtext))) {
+ strcpy(stext, "dwm-"VERSION);
+ estext[0] = '\0';
+ } else {
+ copyvalidchars(rawstext, qtext);
+ char *e = strchr(rawstext, statussep);
+ if (e) {
+ *e = '\0'; e++;
+ strncpy(estext, e, sizeof(estext) - 1);
+ } else {
+ estext[0] = '\0';
+ }
+ strncpy(stext, rawstext, sizeof(stext) - 1);
+ }
+ drawbar(selmon);
+}
+
+void
updatetitle(Client *c)
{
if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
@@ -2656,7 +2705,7 @@ getparentprocess(pid_t p)
#ifdef __linux__
FILE *f;
- char buf[256];
+ char buf[2048];
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
if (!(f = fopen(buf, "r")))
@@ -2749,7 +2798,7 @@ wintomon(Window w)
if (w == root && getrootptr(&x, &y))
return recttomon(x, y, 1, 1);
for (m = mons; m; m = m->next)
- if (w == m->barwin)
+ if (w == m->barwin || w == m->extrabarwin)
return m;
if ((c = wintoclient(w)))
return c->mon;
diff --git a/dwm.c b/dwm.c.orig
diff --git a/dwm.c.rej b/dwm.c.rej
@@ -0,0 +1,32 @@
+--- dwm.c
++++ dwm.c
+@@ -239,6 +241,7 @@ static void zoom(const Arg *arg);
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
++static char estext[256];
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh, blw = 0; /* bar geometry */
+@@ -2010,8 +2034,20 @@ updatesizehints(Client *c)
+ void
+ updatestatus(void)
+ {
+- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
++ char text[512];
++ if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
+ strcpy(stext, "dwm-"VERSION);
++ estext[0] = '\0';
++ } else {
++ char *e = strchr(text, statussep);
++ if (e) {
++ *e = '\0'; e++;
++ strncpy(estext, e, sizeof(estext) - 1);
++ } else {
++ estext[0] = '\0';
++ }
++ strncpy(stext, text, sizeof(stext) - 1);
++ }
+ drawbar(selmon);
+ }
+
diff --git a/patches/dwm-extrabar-6.2.diff b/patches/dwm-extrabar-6.2.diff