[wiki] [sites] updated and simplified dualstatus patch. implementation now using drw. || Andrew Milkovich
commit 44968658e41149b13d4d0df11a306ee76259a697
Author: Andrew Milkovich <amilkovich_AT_gmail.com>
Date: Wed Jun 26 22:46:48 2013 -0700
updated and simplified dualstatus patch. implementation now using drw.
diff --git a/dwm.suckless.org/patches/dualstatus.md b/dwm.suckless.org/patches/dualstatus.md
index 8dbd09a..a09c166 100644
--- a/dwm.suckless.org/patches/dualstatus.md
+++ b/dwm.suckless.org/patches/dualstatus.md
_AT_@ -3,20 +3,21 @@ dualstatus
Description
-----------
-This patch will enable both a top and bottom status bar in dwm. The bottom bar can be toggled along with the top bar or independently.
+This patch will enable an extra status bar in dwm. The extra bar can be toggled along with the standard bar or independently.
The status bar text can be set as follows:
-xsetroot -name "Top textBOTTOM=Bottom text"
+xsetroot -name "Top text;Bottom text"
Download
--------
- * [dwm-6.1-dualstatus.diff](dwm-6.1-dualstatus.diff) (5793b) (20130123)
+ * [dwm-6.1-dualstatus.diff](dwm-6.1-dualstatus.diff) (4655b) (20130626)
Screenshot
----------
a simple dual status bar
+
![alt text](dwm-dualstatus.png)
Authors
diff --git a/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff b/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff
index 3a59d1e..e806220 100644
--- a/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff
+++ b/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff
_AT_@ -1,12 +1,12 @@
diff --git a/config.def.h b/config.def.h
-index 8fd5d4a..6daa608 100644
+index d300687..e286e5d 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -12,6 +12,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const Bool showbar = True; /* False means no bar */
static const Bool topbar = True; /* False means bottom bar */
-+static const Bool bottombar = True; /* True means an extra bar at the bottom */
++static const Bool extrabar = True; /* False means no extra bar */
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
_AT_@ -14,178 +14,141 @@ index 8fd5d4a..6daa608 100644
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
-+ { MODKEY, XK_b, togglebottombar,{0} },
++ { MODKEY, XK_b, toggleextrabar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
diff --git a/dwm.c b/dwm.c
-index d9443da..0d358ca 100644
+index 314adf4..0ab7edc 100644
--- a/dwm.c
+++ b/dwm.c
-_AT_@ -131,6 +131,7 @@ struct Monitor {
- int nmaster;
- int num;
- int by; /* bar geometry */
-+ int bby; /* bottom bar geometry */
- int mx, my, mw, mh; /* screen size */
- int wx, wy, ww, wh; /* window area */
- unsigned int seltags;
-_AT_@ -138,11 +139,14 @@ struct Monitor {
- unsigned int tagset[2];
- Bool showbar;
- Bool topbar;
-+ Bool showbottombar;
-+ Bool bottombar;
- Client *clients;
- Client *sel;
- Client *stack;
- Monitor *next;
- Window barwin;
-+ Window bbarwin;
- const Layout *lt[2];
- };
+_AT_@ -140,6 +140,13 @@ typedef struct {
+ int monitor;
+ } Rule;
-_AT_@ -229,6 +233,7 @@ static void tagmon(const Arg *arg);
- static int textnw(const char *text, unsigned int len);
++typedef struct {
++ int y;
++ Bool show;
++ Window win;
++ char text[256];
++} Bar;
++
+ /* function declarations */
+ static void applyrules(Client *c);
+ static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
+_AT_@ -209,6 +216,7 @@ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
-+static void togglebottombar(const Arg *arg);
++static void toggleextrabar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
-_AT_@ -256,6 +261,7 @@ static void zoom(const Arg *arg);
- /* variables */
- static const char broken[] = "broken";
- static char stext[256];
-+static char btext[256];
- static int screen;
- static int sw, sh; /* X display screen geometry width, height */
- static int bh, blw = 0; /* bar geometry */
-_AT_@ -515,6 +521,8 @@ cleanupmon(Monitor *mon) {
- }
- XUnmapWindow(dpy, mon->barwin);
- XDestroyWindow(dpy, mon->barwin);
-+ XUnmapWindow(dpy, mon->bbarwin);
-+ XDestroyWindow(dpy, mon->bbarwin);
- free(mon);
- }
+_AT_@ -266,6 +274,7 @@ static Drw *drw;
+ static Fnt *fnt;
+ static Monitor *mons, *selmon;
+ static Window root;
++static Bar eb;
-_AT_@ -585,8 +593,10 @@ configurenotify(XEvent *e) {
- XFreePixmap(dpy, dc.drawable);
- dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+_AT_@ -469,6 +478,8 @@ cleanup(void) {
+ while(m->stack)
+ unmanage(m->stack, False);
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
++ XUnmapWindow(dpy, eb.win);
++ XDestroyWindow(dpy, eb.win);
+ while(mons)
+ cleanupmon(mons);
+ drw_cur_free(drw, cursor[CurNormal]);
+_AT_@ -569,6 +580,7 @@ configurenotify(XEvent *e) {
updatebars();
-- for(m = mons; m; m = m->next)
-+ for(m = mons; m; m = m->next) {
+ for(m = mons; m; m = m->next)
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
-+ XMoveResizeWindow(dpy, m->bbarwin, m->wx, m->bby, m->ww, bh);
-+ }
++ XMoveResizeWindow(dpy, eb.win, mons->wx, eb.y, mons->ww, bh);
focus(NULL);
arrange(NULL);
}
-_AT_@ -657,6 +667,8 @@ createmon(void) {
- m->nmaster = nmaster;
- m->showbar = showbar;
- m->topbar = topbar;
-+ m->bottombar = bottombar;
-+ m->showbottombar = bottombar ? True : False;
- m->lt[0] = &layouts[0];
- m->lt[1] = &layouts[1 % LENGTH(layouts)];
- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
-_AT_@ -755,6 +767,15 @@ drawbar(Monitor *m) {
- drawtext(NULL, dc.norm, False);
+_AT_@ -739,6 +751,9 @@ drawbar(Monitor *m) {
+ }
}
- XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
-+ if(m->showbottombar) {
-+ dc.x = 0;
-+ dc.w = TEXTW(btext);
-+ drawtext(btext, dc.norm, False);
-+ dc.x += dc.w;
-+ dc.w = m->ww - dc.x;
-+ drawtext(NULL, dc.norm, False);
-+ XCopyArea(dpy, dc.drawable, m->bbarwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
-+ }
- XSync(dpy, False);
+ drw_map(drw, m->barwin, 0, 0, m->ww, bh);
++ drw_setscheme(drw, &scheme[SchemeNorm]);
++ drw_text(drw, 0, 0, mons->ww, bh, eb.text, 0);
++ drw_map(drw, eb.win, 0, 0, mons->ww, bh);
}
-_AT_@ -1745,6 +1766,14 @@ togglebar(const Arg *arg) {
+ void
+_AT_@ -1503,6 +1518,7 @@ setup(void) {
+ bh = fnt->h + 2;
+ drw = drw_create(dpy, screen, root, sw, sh);
+ drw_setfont(drw, fnt);
++ eb.show = extrabar;
+ updategeom();
+ /* init atoms */
+ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
+_AT_@ -1631,6 +1647,16 @@ togglebar(const Arg *arg) {
}
void
-+togglebottombar(const Arg *arg) {
-+ selmon->showbottombar = !selmon->showbottombar;
-+ updatebarpos(selmon);
-+ XMoveResizeWindow(dpy, selmon->bbarwin, selmon->wx, selmon->bby, selmon->ww, bh);
-+ arrange(selmon);
++toggleextrabar(const Arg *arg) {
++ if(selmon == mons) {
++ eb.show = !eb.show;
++ updatebarpos(selmon);
++ XMoveResizeWindow(dpy, eb.win, selmon->wx, eb.y, selmon->ww, bh);
++ arrange(selmon);
++ }
+}
+
+void
togglefloating(const Arg *arg) {
if(!selmon->sel)
return;
-_AT_@ -1848,6 +1877,13 @@ updatebars(void) {
- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
- XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
+_AT_@ -1735,6 +1761,13 @@ updatebars(void) {
+ XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
XMapRaised(dpy, m->barwin);
-+ if (m->bottombar) {
-+ m->bbarwin = XCreateWindow(dpy, root, m->wx, m->bby, m->ww, bh, 0, DefaultDepth(dpy, screen),
-+ CopyFromParent, DefaultVisual(dpy, screen),
-+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
-+ XDefineCursor(dpy, m->bbarwin, cursor[CurNormal]);
-+ XMapRaised(dpy, m->bbarwin);
-+ }
}
++ if(!eb.win) {
++ eb.win = XCreateWindow(dpy, root, mons->wx, eb.y, mons->ww, bh, 0, DefaultDepth(dpy, screen),
++ CopyFromParent, DefaultVisual(dpy, screen),
++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
++ XDefineCursor(dpy, eb.win, cursor[CurNormal]->cursor);
++ XMapRaised(dpy, eb.win);
++ }
}
-_AT_@ -1862,6 +1898,12 @@ updatebarpos(Monitor *m) {
+ void
+_AT_@ -1748,6 +1781,13 @@ updatebarpos(Monitor *m) {
}
else
m->by = -bh;
-+ if (m->showbottombar) {
++ if(m == mons && eb.show) {
+ m->wh -= bh;
-+ m->bby = m->wy + m->wh;
++ eb.y = topbar ? m->wy + m->wh : m->wy;
++ m->wy = m->topbar ? m->wy : m->wy + bh;
+ }
+ else
-+ m->bby = -bh;
++ eb.y = -bh;
}
void
-_AT_@ -2034,8 +2076,39 @@ updatetitle(Client *c) {
+_AT_@ -1920,8 +1960,19 @@ updatetitle(Client *c) {
void
updatestatus(void) {
- if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
-+ char buftext[512];
-+ if(!gettextprop(root, XA_WM_NAME, buftext, sizeof(buftext)))
++ char text[512];
++ if(!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
strcpy(stext, "dwm-"VERSION);
++ eb.text[0] = '
Received on Thu Jun 27 2013 - 07:47:49 CEST
This archive was generated by hypermail 2.3.0
: Thu Jun 27 2013 - 07:48:18 CEST