[wiki] [sites] dualstatus patch added || Andrew Milkovich
commit 243dfa43e38897d1eae0e2c93b216173a6c87af1
Author: Andrew Milkovich <amilkovich_AT_gmail.com>
Date: Wed Jan 23 11:37:50 2013 -0800
dualstatus patch added
diff --git a/dwm.suckless.org/patches/dualstatus.md b/dwm.suckless.org/patches/dualstatus.md
new file mode 100644
index 0000000..8dbd09a
--- /dev/null
+++ b/dwm.suckless.org/patches/dualstatus.md
_AT_@ -0,0 +1,24 @@
+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.
+
+The status bar text can be set as follows:
+xsetroot -name "Top textBOTTOM=Bottom text"
+
+Download
+--------
+
+ * [dwm-6.1-dualstatus.diff](dwm-6.1-dualstatus.diff) (5793b) (20130123)
+
+Screenshot
+----------
+
+a simple dual status bar
+![alt text](dwm-dualstatus.png)
+
+Authors
+-------
+ * Andrew Milkovich - `<amilkovich at gmail dot com>`
diff --git a/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff b/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff
new file mode 100644
index 0000000..3a59d1e
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-6.1-dualstatus.diff
_AT_@ -0,0 +1,192 @@
+diff --git a/config.def.h b/config.def.h
+index 8fd5d4a..6daa608 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 */
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+_AT_@ -58,6 +59,7 @@ static Key keys[] = {
+ { 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_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
+--- 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_@ -229,6 +233,7 @@ static void tagmon(const Arg *arg);
+ static int textnw(const char *text, unsigned int len);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
++static void togglebottombar(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_@ -585,8 +593,10 @@ configurenotify(XEvent *e) {
+ XFreePixmap(dpy, dc.drawable);
+ dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
+ updatebars();
+- 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);
++ }
+ 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);
+ }
+ 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);
+ }
+
+_AT_@ -1745,6 +1766,14 @@ 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);
++}
++
++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]);
+ 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);
++ }
+ }
+ }
+
+_AT_@ -1862,6 +1898,12 @@ updatebarpos(Monitor *m) {
+ }
+ else
+ m->by = -bh;
++ if (m->showbottombar) {
++ m->wh -= bh;
++ m->bby = m->wy + m->wh;
++ }
++ else
++ m->bby = -bh;
+ }
+
+ void
+_AT_@ -2034,8 +2076,39 @@ 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)))
+ strcpy(stext, "dwm-"VERSION);
++ else {
++ char* blocation = strstr(buftext,"BOTTOM=");
++ if (blocation != NULL) {
++ int c = 0;
++ for (char* i = buftext; i < blocation; i++) {
++ if (c < sizeof(stext) - 1)
++ stext[c] = *i;
++ else
++ break;
++ c++;
++ }
++ stext[c] = '
Received on Wed Jan 23 2013 - 20:38:38 CET
This archive was generated by hypermail 2.3.0
: Wed Jan 23 2013 - 20:48:05 CET